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

Commit

Permalink
dark mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLuo0 committed Aug 10, 2019
1 parent 152a86c commit c4b29a3
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 178 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.RichardLuo.notificationpush"
minSdkVersion 22
targetSdkVersion 28
versionCode 17
versionName "1.1.2"
versionCode 19
versionName "1.1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -24,8 +24,8 @@ dependencies {
implementation 'androidx.media:media:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -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":{}}]
[{"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":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
Expand Down Expand Up @@ -125,4 +133,11 @@ class info {
}
}.start();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home)
finish();
return true;
}
}
87 changes: 24 additions & 63 deletions app/src/main/java/com/RichardLuo/notificationpush/FCMReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
import android.content.pm.ApplicationInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.*;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.Build;
import android.service.notification.StatusBarNotification;

import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.Person;
import androidx.core.graphics.drawable.IconCompat;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

Expand Down Expand Up @@ -90,18 +98,23 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
Cursor cursor;
if (senderName.equals(title)) {
db = SQLiteDatabase.openOrCreateDatabase(this.getDatabasePath("friends.db"), null);
cursor = db.query("friends", new String[]{"uin"}, "name ='" + senderName + "'", null, null, null, null);
cursor = db.query("friends", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
} else if (getSharedPreferences("groups", MODE_PRIVATE).contains(title)) {
db = SQLiteDatabase.openOrCreateDatabase(this.getDatabasePath("friends.db"), null);
cursor = db.query("'" + title + "'", new String[]{"uin"}, "name ='" + senderName + "'", null, null, null, null);
Cursor cursorTemp = db.query("'" + title + "'", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
if (cursorTemp.getCount() == 0) {
cursorTemp.close();
cursor = db.query("friends", new String[]{"uin"}, "name ='" + encodeSendername + "'", null, null, null, null);
} else cursor = cursorTemp;
} else
break out;
if (cursor.getCount() != 0) {
if (cursor.moveToFirst()) {
String QQnumber = cursor.getString(0);
cursor.close();
db.close();
HttpURLConnection connection = (HttpURLConnection) new URL("https://qlogo3.store.qq.com/qzone/" + QQnumber + "/" + QQnumber + "/50.png").openConnection();
HttpURLConnection connection = (HttpURLConnection) new URL("https://q4.qlogo.cn/g?b=qq&s=140&nk=" + QQnumber).openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setConnectTimeout(1000);
connection.setReadTimeout(1000);
Expand Down Expand Up @@ -244,10 +257,13 @@ private void MessagingStyle(String packageName, String AppName, String title, St
style = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(current);
style.addMessage(message, new Date().getTime(), sender);
} else {
style = new NotificationCompat.MessagingStyle(sender)
.setConversationTitle(title)
.setGroupConversation(true)
.addMessage(message, new Date().getTime(), sender);
style = new NotificationCompat.MessagingStyle(sender);
if (title.equals(senderName))
style.setGroupConversation(false);
else {
style.setConversationTitle(title).setGroupConversation(true);
}
style.addMessage(message, new Date().getTime(), sender);
}

Notification notification = new NotificationCompat.Builder(this, AppName)
Expand All @@ -262,59 +278,4 @@ private void MessagingStyle(String packageName, String AppName, String title, St
.build();
notificationManagerCompat.notify(packageName, ID, notification);
}

/*private void forQQ(String packageName, String title, String body, PendingIntent intent, NotificationManagerCompat notificationManagerCompat) {
setChannel(packageName);
Notification notification;
if (!(body.contains("联系人给你") || title.contains("QQ空间") || body.contains("你收到了"))) {
int TitleID = StringToA(title.split("\\s\\(")[0]);
String[] bodySplit = body.split(":");
Person sender;
String message;
if (bodySplit.length == 1 || body.split("\\s")[0].equals("")) {
sender = new Person.Builder()
.setName(title.split("\\s\\(")[0])
.build();
message = body;
} else {
sender = new Person.Builder()
.setName(bodySplit[0])
.build();
message = bodySplit[1];
}
NotificationCompat.MessagingStyle style;
Notification current;
if (!((current = getCurrentNotification(packageName, TitleID)) == null)) {
style = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(current);
style.addMessage(message, new Date().getTime(), sender);
} else {
style = new NotificationCompat.MessagingStyle(sender)
.setConversationTitle(title)
.addMessage(message, new Date().getTime(), sender);
}
notification = new NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.ic_notification)
.setColor(color)
.setContentTitle(packageName)
.setStyle(style)
.setGroup(packageName)
.setContentIntent(intent)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.build();
notificationManagerCompat.notify(packageName, TitleID, notification);
} else {
notification = new NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.ic_notification)
.setColor(color)
.setContentTitle(title)
.setContentText(body)
.setGroup(packageName)
.setContentIntent(intent)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.build();
notificationManagerCompat.notify(packageName, 0, notification);
}
}*/
}
Loading

0 comments on commit c4b29a3

Please sign in to comment.