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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ NotiFilter listens to all device notifications and quietly manages those that ma
8. Play an alert 🔔
- **Schedule** - Choose when filters run (e.g. only during work hours) ⏰
- **History** - Recently dismissed notifications are stored (locally), just in case 😉
- **Widget** - Configure filters to send notifications to a home screen widget 📱
- **Export/Import** - Backup or transfer your filters as JSON files 📂
- **Free, open-source & private**
- No ads, subscriptions, or in-app purchases 🆓
Expand Down
8 changes: 6 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId = "co.adityarajput.notifilter"
minSdk = 29
targetSdk = 36
versionCode = 21
versionName = "4.4.0"
versionCode = 22
versionName = "4.5.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -84,11 +84,15 @@ dependencies {
ksp(libs.androidx.room.compiler)
implementation(libs.kotlinx.serialization.json)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.glance.appwidget)
implementation(libs.androidx.glance.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)
debugImplementation(libs.androidx.glance.preview)
debugImplementation(libs.androidx.glance.appwidget.preview)
}
165 changes: 165 additions & 0 deletions app/schemas/co.adityarajput.notifilter.data.NotiFilterDatabase/11.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"formatVersion": 1,
"database": {
"version": 11,
"identityHash": "5a4d946a922bfa0ba8b42571ca3b51da",
"entities": [
{
"tableName": "filters",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`regexPattern` TEXT NOT NULL, `action` TEXT NOT NULL, `regexTarget` TEXT NOT NULL, `secondaryRegexPattern` TEXT, `enabled` INTEGER NOT NULL, `historyEnabled` INTEGER NOT NULL, `widgetEnabled` INTEGER NOT NULL DEFAULT 0, `hits` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `app_name` TEXT NOT NULL, `app_packageName` TEXT NOT NULL, `schedule_start` INTEGER NOT NULL, `schedule_end` INTEGER NOT NULL, `schedule_days` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "regexPattern",
"columnName": "regexPattern",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "action",
"columnName": "action",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "regexTarget",
"columnName": "regexTarget",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "secondaryRegexPattern",
"columnName": "secondaryRegexPattern",
"affinity": "TEXT"
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "historyEnabled",
"columnName": "historyEnabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "widgetEnabled",
"columnName": "widgetEnabled",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "hits",
"columnName": "hits",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "app.name",
"columnName": "app_name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "app.packageName",
"columnName": "app_packageName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "schedule.start",
"columnName": "schedule_start",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "schedule.end",
"columnName": "schedule_end",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "schedule.days",
"columnName": "schedule_days",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
}
},
{
"tableName": "notifications",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `content` TEXT NOT NULL, `origin` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, `showInHistory` INTEGER NOT NULL DEFAULT 1, `showInWidget` INTEGER NOT NULL DEFAULT 0, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "content",
"columnName": "content",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "origin",
"columnName": "origin",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "showInHistory",
"columnName": "showInHistory",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showInWidget",
"columnName": "showInWidget",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
}
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5a4d946a922bfa0ba8b42571ca3b51da')"
]
}
}
17 changes: 17 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<!-- region Remove unused permission(s) added by WorkManager -->
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove" />
<!-- endregion -->

<application
android:name=".NotiFilterApplication"
android:allowBackup="true"
Expand All @@ -32,6 +38,17 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".WidgetReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>


<service
android:name=".services.NotificationListener"
Expand Down
13 changes: 1 addition & 12 deletions app/src/main/java/co/adityarajput/notifilter/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import co.adityarajput.notifilter.data.Cache
import co.adityarajput.notifilter.views.Navigator
Expand All @@ -54,16 +51,8 @@ class MainActivity : ComponentActivity() {
Surface(
Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
NotiFilter()
}
) { Navigator(rememberNavController()) }
}
}
}
}

@Preview
@Composable
fun NotiFilter(navController: NavHostController = rememberNavController()) {
Navigator(navController)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package co.adityarajput.notifilter
import android.app.Application
import android.content.pm.ApplicationInfo
import co.adityarajput.notifilter.data.AppContainer
import co.adityarajput.notifilter.utils.pushWidgetPreview
import co.adityarajput.notifilter.utils.subscribeWidgetToFlow
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch

class NotiFilterApplication : Application() {
lateinit var container: AppContainer
Expand All @@ -16,5 +22,10 @@ class NotiFilterApplication : Application() {
// INFO: While debugging, populate database with demo data for screenshots
container.seedDemoData()
}

CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
[email protected]()
subscribeWidgetToFlow(this@NotiFilterApplication, container.repository.log())
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.adityarajput.notifilter

import androidx.glance.appwidget.GlanceAppWidgetReceiver
import co.adityarajput.notifilter.views.Widget

class WidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget = Widget()
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class AppContainer(private val context: Context) {
"[Nn]ewsletter",
Action.BATCH(3),
RegexTarget.OR,
historyEnabled = false,
widgetEnabled = true,
hits = 1,
),
Filter(
App("WhatsApp", "com.whatsapp"),
Expand Down Expand Up @@ -86,7 +87,7 @@ class AppContainer(private val context: Context) {
"Update available",
Action.ALERT,
RegexTarget.AND,
"NotiFilter",
"NotiFilter|Alarmetrics|FileFlow",
historyEnabled = false,
),
Filter(
Expand Down Expand Up @@ -121,6 +122,7 @@ class AppContainer(private val context: Context) {
"The week: a microphone, a ropeway, and something very sour.\nHello!\nOver the last few days...",
"Gmail",
System.currentTimeMillis() - 3 * 60 * 60 * 1000,
showInWidget = true,
),
Notification(
"Book Club",
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/adityarajput/notifilter/data/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import co.adityarajput.notifilter.data.models.Notification

@Database(
entities = [Filter::class, Notification::class],
version = 10,
version = 11,
autoMigrations = [
AutoMigration(1, 2), AutoMigration(2, 3), AutoMigration(3, 4),
AutoMigration(4, 5), AutoMigration(5, 6),
AutoMigration(6, 7, NotiFilterDatabase.DeleteTableAN::class),
AutoMigration(7, 8), AutoMigration(8, 9),
AutoMigration(7, 8), AutoMigration(8, 9), AutoMigration(10, 11),
],
)
@TypeConverters(Converters::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ interface NotificationDao {
@Query("SELECT * FROM notifications ORDER BY id DESC")
fun list(): Flow<List<Notification>>

@Query("SELECT * FROM notifications WHERE showInHistory = 1 ORDER BY id DESC")
fun history(): Flow<List<Notification>>

@Query("SELECT * FROM notifications WHERE showInWidget = 1 ORDER BY id DESC")
fun widget(): Flow<List<Notification>>

@Query("SELECT COUNT(*) FROM notifications")
suspend fun count(): Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class Repository(

fun notifications() = notificationDao.list()

fun history() = notificationDao.history()

fun log() = notificationDao.widget()

suspend fun registerHit(filter: Filter, notification: Notification) {
filterDao.registerHit(filter.id)
notificationDao.upsert(notification)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.adityarajput.notifilter.data.models

import androidx.room.ColumnInfo
import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.PrimaryKey
Expand All @@ -26,6 +27,9 @@ data class Filter(

val historyEnabled: Boolean = true,

@ColumnInfo(defaultValue = "0")
val widgetEnabled: Boolean = false,

val hits: Int = 0,

@PrimaryKey(autoGenerate = true)
Expand Down
Loading