Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"proguard/nightly.pro",
)
applicationIdSuffix = ".nightly"
resValue("string", "app_name_launcher", "NotiFilter Nightly")
Expand All @@ -46,7 +46,7 @@ android {
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"proguard/release.pro",
)
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/proguard/nightly.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-assumenosideeffects class android.util.Log {
public static int d(...);
public static int i(...);
public static int e(...);
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro → app/proguard/release.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
}

-assumenosideeffects class co.adityarajput.notifilter.utils.Logger {
public final int d(...);
public final void d(...);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.app.NotificationManager
import android.content.pm.ApplicationInfo
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build
import android.os.Build.VERSION_CODES.BAKLAVA
import android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE
import android.service.notification.NotificationListenerService
import android.service.notification.StatusBarNotification
import androidx.core.app.NotificationCompat
Expand Down Expand Up @@ -90,7 +92,7 @@ class NotificationListener : NotificationListenerService() {
.setContentTitle(getString(R.string.app_name_launcher))
.setContentText(getString(R.string.foreground_notification_content))
.setOngoing(true).setSilent(true).build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) FOREGROUND_SERVICE_TYPE_SPECIAL_USE else 0,
if (Build.VERSION.SDK_INT >= UPSIDE_DOWN_CAKE) FOREGROUND_SERVICE_TYPE_SPECIAL_USE else 0,
)
Logger.i("NotificationListener.startForeground", "Promoted to foreground")
}
Expand Down Expand Up @@ -133,14 +135,24 @@ class NotificationListener : NotificationListenerService() {
is Action.TAP_NOTIFICATION ->
try {
sbn.notification.contentIntent?.run {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.BAKLAVA) send() else
if (Build.VERSION.SDK_INT >= BAKLAVA) {
send(
ActivityOptions.makeBasic()
.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS,
)
.toBundle(),
)
} else if (Build.VERSION.SDK_INT >= UPSIDE_DOWN_CAKE) {
@Suppress("DEPRECATION")
send(
ActivityOptions.makeBasic()
.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED,
)
.toBundle(),
)
} else send()
}
} catch (e: Exception) {
Logger.e(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import co.adityarajput.notifilter.Constants
object Logger {
val logs = ArrayDeque<String>(Constants.LOG_SIZE)

fun d(tag: String, msg: String) = Log.d(tag, msg)
fun d(tag: String, msg: String) {
Log.d(tag, msg)

if (logs.size >= Constants.LOG_SIZE) logs.removeFirst()
logs.addLast("[${System.currentTimeMillis()}][$tag][DEBUG] $msg")
}

fun i(tag: String, msg: String) {
Log.i(tag, msg)
Expand Down