Skip to content

Commit

Permalink
Updated gradle version
Browse files Browse the repository at this point in the history
  • Loading branch information
choiman1559 committed Mar 25, 2023
1 parent db48927 commit 13f7a08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 56 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
applicationId "com.noti.main"
minSdkVersion 21
targetSdkVersion 33
versionCode 1011901
versionName "1.19.1"
versionCode 1011902
versionName "1.19.2"
multiDexEnabled true
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
77 changes: 23 additions & 54 deletions app/src/main/java/com/noti/main/service/NotiListenerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.Telephony;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.telecom.TelecomManager;
Expand Down Expand Up @@ -205,6 +204,10 @@ private String getSystemDialerApp(Context context) {
}
}

private boolean isTelephonyApp(String packageName) {
return Telephony.Sms.getDefaultSmsPackage(this).equals(packageName) || getSystemDialerApp(this).equals(packageName);
}

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
Expand Down Expand Up @@ -238,13 +241,9 @@ public void onNotificationPosted(StatusBarNotification sbn) {
if (PackageName.equals(getPackageName()) && (!TITLE.toLowerCase().contains("test") || TITLE.contains("main"))) {
manager.release();
return;
} else if (prefs.getBoolean("UseReplyTelecom", false) && getSystemDialerApp(this).equals(PackageName)) {
if (prefs.getBoolean("UseCallLog", false))
sendTelecomNotification(isLogging, PackageName, time);
else {
manager.release();
return;
}
} else if(isTelephonyApp(PackageName)) {
manager.release();
return;
} else if (isWhitelist(PackageName)) {
if (prefs.getBoolean("IgnoreOngoing", false) &&
(notification.flags & Notification.FLAG_FOREGROUND_SERVICE) != 0 ||
Expand Down Expand Up @@ -302,12 +301,14 @@ public void onNotificationPosted(StatusBarNotification sbn) {
}
}

private void sendTelecomNotification(Boolean isLogging, String PackageName, Date time) {
Cursor cursor = getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, null, android.provider.CallLog.Calls.TYPE + "=" + CallLog.Calls.INCOMING_TYPE, null, null);
cursor.moveToFirst();
String address = cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER));
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date(Long.parseLong(cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.DATE)))));
cursor.close();
public void sendTelecomNotification(Context context, Boolean isLogging, String address) {
if (prefs == null) {
prefs = context.getSharedPreferences(Application.PREFS_NAME, MODE_PRIVATE);
}

Date time = Calendar.getInstance().getTime();
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(time);
String PackageName = getSystemDialerApp(context);

if (isTelecomIntervalGaped(address, time)) {
String DEVICE_NAME = Build.MANUFACTURER + " " + Build.MODEL;
Expand All @@ -330,48 +331,14 @@ private void sendTelecomNotification(Boolean isLogging, String PackageName, Date
if (isLogging) Log.e("Noti", "onCreate: " + e.getMessage());
}
if (isLogging) Log.d("data", notificationHead.toString());
sendNotification(notificationHead, PackageName, this);
sendNotification(notificationHead, PackageName, context);
}
}

public void sendTelecomNotification(Context context, Boolean isLogging, String address) {
if (prefs == null)
prefs = context.getSharedPreferences(Application.PREFS_NAME, MODE_PRIVATE);
if (prefs.getBoolean("UseReplyTelecom", false) && !prefs.getBoolean("UseCallLog", false)) {
Date time = Calendar.getInstance().getTime();
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(time);
String PackageName = getSystemDialerApp(context);

if (isTelecomIntervalGaped(address, time)) {
String DEVICE_NAME = Build.MANUFACTURER + " " + Build.MODEL;
String DEVICE_ID = getUniqueID();
String TOPIC = "/topics/" + prefs.getString("UID", "");

JSONObject notificationHead = new JSONObject();
JSONObject notificationBody = new JSONObject();
try {
notificationBody.put("type", "send|telecom");
notificationBody.put("address", address);
notificationBody.put("package", PackageName);
notificationBody.put("device_name", DEVICE_NAME);
notificationBody.put("device_id", DEVICE_ID);
notificationBody.put("date", date);

notificationHead.put("to", TOPIC);
notificationHead.put("data", notificationBody);
} catch (JSONException e) {
if (isLogging) Log.e("Noti", "onCreate: " + e.getMessage());
}
if (isLogging) Log.d("data", notificationHead.toString());
sendNotification(notificationHead, PackageName, context);
}
}
}

public void sendSmsNotification(Boolean isLogging, String PackageName, String address, String message, Date time) {
public void sendSmsNotification(Context context, Boolean isLogging, String PackageName, String address, String message, Date time) {
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(time);

if (isSmsIntervalGaped(address, message, time)) {
if (isSmsIntervalGaped(context, address, message, time)) {
String DEVICE_NAME = Build.MANUFACTURER + " " + Build.MODEL;
String DEVICE_ID = getUniqueID();
String TOPIC = "/topics/" + prefs.getString("UID", "");
Expand All @@ -392,7 +359,7 @@ public void sendSmsNotification(Boolean isLogging, String PackageName, String ad
if (isLogging) Log.e("Noti", "onCreate: " + e.getMessage());
}
if (isLogging) Log.d("data", notificationHead.toString());
sendNotification(notificationHead, PackageName, this);
sendNotification(notificationHead, PackageName, context);
}
}

Expand Down Expand Up @@ -543,7 +510,9 @@ private boolean isTelecomIntervalGaped(String Number, Date time) {
return true;
}

private boolean isSmsIntervalGaped(String Number, String Content, Date time) {
private boolean isSmsIntervalGaped(Context context, String Number, String Content, Date time) {
if (prefs == null)
prefs = context.getSharedPreferences(Application.PREFS_NAME, MODE_PRIVATE);
if (prefs.getBoolean("UseInterval", false)) {
int timeInterval = prefs.getInt("IntervalTime", 150);
SmsQuery query = new SmsQuery();
Expand Down

0 comments on commit 13f7a08

Please sign in to comment.