Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit c4b29a3

Browse files
committed
dark mode support
1 parent 152a86c commit c4b29a3

16 files changed

Lines changed: 207 additions & 178 deletions

File tree

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "com.RichardLuo.notificationpush"
77
minSdkVersion 22
88
targetSdkVersion 28
9-
versionCode 17
10-
versionName "1.1.2"
9+
versionCode 19
10+
versionName "1.1.3"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
@@ -24,8 +24,8 @@ dependencies {
2424
implementation 'androidx.media:media:1.0.1'
2525
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
2626
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
27-
implementation 'com.google.firebase:firebase-core:16.0.9'
28-
implementation 'com.google.firebase:firebase-messaging:18.0.0'
27+
implementation 'com.google.firebase:firebase-core:17.0.1'
28+
implementation 'com.google.firebase:firebase-messaging:19.0.1'
2929
testImplementation 'junit:junit:4.12'
3030
androidTestImplementation 'androidx.test:runner:1.2.0'
3131
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

app/release/app-release.apk

2.39 KB
Binary file not shown.

app/release/output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":17,"versionName":"1.1.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":19,"versionName":"1.1.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

app/src/main/java/com/RichardLuo/notificationpush/Application.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
import android.os.Bundle;
88
import android.os.Handler;
99
import android.view.LayoutInflater;
10+
import android.view.MenuItem;
1011
import android.view.View;
1112
import android.view.ViewGroup;
12-
import android.widget.*;
13+
import android.widget.AdapterView;
14+
import android.widget.BaseAdapter;
15+
import android.widget.ImageView;
16+
import android.widget.ListView;
17+
import android.widget.ProgressBar;
18+
import android.widget.Spinner;
19+
import android.widget.TextView;
20+
1321
import androidx.appcompat.app.AppCompatActivity;
1422

1523
import java.util.ArrayList;
@@ -125,4 +133,11 @@ class info {
125133
}
126134
}.start();
127135
}
136+
137+
@Override
138+
public boolean onOptionsItemSelected(MenuItem item) {
139+
if (item.getItemId() == android.R.id.home)
140+
finish();
141+
return true;
142+
}
128143
}

app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java

Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
import android.content.pm.ApplicationInfo;
88
import android.database.Cursor;
99
import android.database.sqlite.SQLiteDatabase;
10-
import android.graphics.*;
10+
import android.graphics.Bitmap;
11+
import android.graphics.BitmapFactory;
12+
import android.graphics.Canvas;
13+
import android.graphics.Paint;
14+
import android.graphics.PorterDuff;
15+
import android.graphics.PorterDuffXfermode;
16+
import android.graphics.Rect;
1117
import android.os.Build;
1218
import android.service.notification.StatusBarNotification;
19+
1320
import androidx.core.app.NotificationCompat;
1421
import androidx.core.app.NotificationManagerCompat;
1522
import androidx.core.app.Person;
1623
import androidx.core.graphics.drawable.IconCompat;
24+
1725
import com.google.firebase.messaging.FirebaseMessagingService;
1826
import com.google.firebase.messaging.RemoteMessage;
1927

@@ -90,18 +98,23 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
9098
Cursor cursor;
9199
if (senderName.equals(title)) {
92100
db = SQLiteDatabase.openOrCreateDatabase(this.getDatabasePath("friends.db"), null);
93-
cursor = db.query("friends", new String[]{"uin"}, "name ='" + senderName + "'", null, null, null, null);
101+
cursor = db.query("friends", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
94102
} else if (getSharedPreferences("groups", MODE_PRIVATE).contains(title)) {
95103
db = SQLiteDatabase.openOrCreateDatabase(this.getDatabasePath("friends.db"), null);
96-
cursor = db.query("'" + title + "'", new String[]{"uin"}, "name ='" + senderName + "'", null, null, null, null);
104+
Cursor cursorTemp = db.query("'" + title + "'", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
105+
if (cursorTemp.getCount() == 0) {
106+
cursorTemp.close();
107+
cursor = db.query("friends", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
108+
} else cursor = cursorTemp;
97109
} else
98110
break out;
99111
if (cursor.getCount() != 0) {
100112
if (cursor.moveToFirst()) {
101113
String QQnumber = cursor.getString(0);
102114
cursor.close();
103115
db.close();
104-
HttpURLConnection connection = (HttpURLConnection) new URL("https://qlogo3.store.qq.com/qzone/" + QQnumber + "/" + QQnumber + "/50.png").openConnection();
116+
HttpURLConnection connection = (HttpURLConnection) new URL("https://q4.qlogo.cn/g?b=qq&s=140&nk=" + QQnumber).openConnection();
117+
connection.setRequestMethod("GET");
105118
connection.setDoInput(true);
106119
connection.setConnectTimeout(1000);
107120
connection.setReadTimeout(1000);
@@ -244,10 +257,13 @@ private void MessagingStyle(String packageName, String AppName, String title, St
244257
style = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(current);
245258
style.addMessage(message, new Date().getTime(), sender);
246259
} else {
247-
style = new NotificationCompat.MessagingStyle(sender)
248-
.setConversationTitle(title)
249-
.setGroupConversation(true)
250-
.addMessage(message, new Date().getTime(), sender);
260+
style = new NotificationCompat.MessagingStyle(sender);
261+
if (title.equals(senderName))
262+
style.setGroupConversation(false);
263+
else {
264+
style.setConversationTitle(title).setGroupConversation(true);
265+
}
266+
style.addMessage(message, new Date().getTime(), sender);
251267
}
252268

253269
Notification notification = new NotificationCompat.Builder(this, AppName)
@@ -262,59 +278,4 @@ private void MessagingStyle(String packageName, String AppName, String title, St
262278
.build();
263279
notificationManagerCompat.notify(packageName, ID, notification);
264280
}
265-
266-
/*private void forQQ(String packageName, String title, String body, PendingIntent intent, NotificationManagerCompat notificationManagerCompat) {
267-
setChannel(packageName);
268-
Notification notification;
269-
if (!(body.contains("联系人给你") || title.contains("QQ空间") || body.contains("你收到了"))) {
270-
int TitleID = StringToA(title.split("\\s\\(")[0]);
271-
String[] bodySplit = body.split(":");
272-
Person sender;
273-
String message;
274-
if (bodySplit.length == 1 || body.split("\\s")[0].equals("")) {
275-
sender = new Person.Builder()
276-
.setName(title.split("\\s\\(")[0])
277-
.build();
278-
message = body;
279-
} else {
280-
sender = new Person.Builder()
281-
.setName(bodySplit[0])
282-
.build();
283-
message = bodySplit[1];
284-
}
285-
NotificationCompat.MessagingStyle style;
286-
Notification current;
287-
if (!((current = getCurrentNotification(packageName, TitleID)) == null)) {
288-
style = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(current);
289-
style.addMessage(message, new Date().getTime(), sender);
290-
} else {
291-
style = new NotificationCompat.MessagingStyle(sender)
292-
.setConversationTitle(title)
293-
.addMessage(message, new Date().getTime(), sender);
294-
}
295-
notification = new NotificationCompat.Builder(this, packageName)
296-
.setSmallIcon(R.drawable.ic_notification)
297-
.setColor(color)
298-
.setContentTitle(packageName)
299-
.setStyle(style)
300-
.setGroup(packageName)
301-
.setContentIntent(intent)
302-
.setAutoCancel(true)
303-
.setOnlyAlertOnce(true)
304-
.build();
305-
notificationManagerCompat.notify(packageName, TitleID, notification);
306-
} else {
307-
notification = new NotificationCompat.Builder(this, packageName)
308-
.setSmallIcon(R.drawable.ic_notification)
309-
.setColor(color)
310-
.setContentTitle(title)
311-
.setContentText(body)
312-
.setGroup(packageName)
313-
.setContentIntent(intent)
314-
.setAutoCancel(true)
315-
.setOnlyAlertOnce(true)
316-
.build();
317-
notificationManagerCompat.notify(packageName, 0, notification);
318-
}
319-
}*/
320281
}

0 commit comments

Comments
 (0)