Closed zezung27 closed 1 year ago
textNoti = bundle.containsKey("android.text") && bundle.getCharSequence("android.text") != null ? bundle.getCharSequence("android.text", (CharSequence)"") : ""; bigTextNoti = bundle.containsKey("android.bigText") && bundle.getCharSequence("android.bigText") != null ? bundle.getCharSequence("android.bigText", (CharSequence)"") : ""; subName = bundle.containsKey("android.substName") && bundle.getString("android.substName") != null ? bundle.getString("android.substName", "") : ""; subText = bundle.containsKey("android.subText") && bundle.getCharSequence("android.subText") != null ? bundle.getCharSequence("android.subText", (CharSequence)"") : ""; summaryText = bundle.containsKey("android.summaryText") && bundle.getCharSequence("android.summaryText") != null ? bundle.getCharSequence("android.summaryText", (CharSequence)"") : ""; textBig = bundle.containsKey("android.title.big") && bundle.getCharSequence("android.title.big") != null ? bundle.getCharSequence("android.title.big", (CharSequence)"") : ""; infoText = bundle.containsKey("android.infoText") && bundle.getString("android.infoText") != null ? bundle.getString("android.infoText", "") : ""; progressMax = bundle.containsKey("android.progressMax") ? bundle.getInt("android.progressMax", 0) : 0; progress = bundle.containsKey("android.progress") ? bundle.getInt("android.progress", 0) : 0; progressIndeterminate = bundle.containsKey("android.progressIndeterminate") ? bundle.getBoolean("android.progressIndeterminate", false) : false; showChronometer = bundle.containsKey("android.showChronometer") ? bundle.getBoolean("android.showChronometer", false) : false; } else { isGroupConversation = false; title=""; }
StringBuilder stringBuilder = new StringBuilder();
Intent intent = new Intent(Contanst.NOTI_INTENT_LOCAL_BROADCAST);
intent.putExtra("isGroupConversation", isGroupConversation);
if (Build.VERSION.SDK_INT >= 30) {
intent.putExtra("isAppGroup", statusBarNotification.isAppGroup());
}
if (Build.VERSION.SDK_INT >= 24) {
intent.putExtra("isGroup", statusBarNotification.isGroup());
}
intent.putExtra("isOngoing", statusBarNotification.isOngoing());
intent.putExtra("tag", statusBarNotification.getTag());
if (Build.VERSION.SDK_INT >= 29) {
intent.putExtra("uId", statusBarNotification.getUid());
}
intent.putExtra("group_key", statusBarNotification.getGroupKey());
intent.putExtra("key", statusBarNotification.getKey());
intent.putExtra("id", idNoti);
intent.putExtra("package", statusBarNotification.getPackageName());
intent.putExtra("ticker", ticket);
intent.putExtra("appName", appName);
intent.putExtra("title", (CharSequence)title);
intent.putExtra("isAdded", bl);
intent.putExtra("postTime", statusBarNotification.getNotification().when);
intent.putExtra("text", textNoti);
intent.putExtra("bigText", bigTextNoti);
intent.putExtra("isClearable", statusBarNotification.isClearable());
intent.putExtra("color", statusBarNotification.getNotification().color);
intent.putExtra("largeIcon", Utils.getByteArrayFromBitmap(bitmap3));
intent.putExtra("substName", subName);
intent.putExtra("subText", subText);
intent.putExtra("titleBig", textBig);
intent.putExtra("summaryText", summaryText);
intent.putExtra("info_text", infoText);
intent.putExtra("template", template);
intent.putExtra("progressMax", progressMax);
intent.putExtra("progress", progress);
intent.putExtra("progressIndeterminate", progressIndeterminate);
intent.putExtra("category", category);
intent.putExtra("showChronometer", showChronometer);
if (statusBarNotification.getNotification().extras.get("android.picture") != null && (bitmap = (Bitmap)statusBarNotification.getNotification().extras.getParcelable("android.picture")) != null) {
intent.putExtra("picture", Utils.getByteArrayFromBitmap2(bitmap));
}
if (bitmap5 == null) {
intent.putExtra("icon", Utils.getByteArrayFromBitmap(Utils.drawableToBmp(null, ContextCompat.getDrawable((Context)this.context, (int) R.drawable.ic_launcher_foreground), 20)));
} else {
intent.putExtra("icon", Utils.getByteArrayFromBitmap(bitmap5));
}
intent.putExtra("pendingIntent", (Parcelable)statusBarNotification.getNotification().contentIntent);
if (statusBarNotification.getNotification().actions != null && statusBarNotification.getNotification().actions.length > 0) {
intent.putExtra("actions", NotificationService.getParsableActions(statusBarNotification.getNotification().actions));
}
return intent;
}
}
package com.matcos.dynamicislandlight.core.service;
import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.RemoteInput; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.text.TextUtils; import android.util.Log;
import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.matcos.dynamicislandlight.R; import com.matcos.dynamicislandlight.core.service.modal.ActionParsable; import com.matcos.dynamicislandlight.noti.PackageModalPref; import com.matcos.dynamicislandlight.utils.Contanst; import com.matcos.dynamicislandlight.utils.Utils;
import java.util.ArrayList; import java.util.stream.Collectors;
public class NotificationService extends NotificationListenerService { private String TAG = this .getClass().getSimpleName() ; Context context ; @Override public void onCreate () { super.onCreate() ; context = getApplicationContext() ; } private void initNoti(StatusBarNotification sbn) { // NotificationManager manager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); // manager.cancel(sbn.getId()); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // manager.deleteNotificationChannel(String.valueOf(sbn.getId())); // } Intent intent = sendNotification(sbn, true); LocalBroadcastManager.getInstance((Context)this.context).sendBroadcast(intent); } @Override public void onNotificationPosted (StatusBarNotification sbn) { ArrayList mList = Utils.getArrayList(Contanst.NAME_PACKAGE, context) ;
if(mList != null && mList.size() > 0) {
String namePackage = sbn.getPackageName();
ArrayList filterPackage= (ArrayList) mList.stream().filter(data -> (data.getPackageName().contains(namePackage) && data.isCheck())).collect(Collectors.toList());
if(filterPackage.size() > 0) {
initNoti(sbn);
}
} else {
initNoti(sbn);
}
}