Skip to content

Commit

Permalink
clear all unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
aj3423 committed Oct 10, 2024
1 parent 7d3d76d commit 79f912b
Show file tree
Hide file tree
Showing 49 changed files with 48 additions and 194 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Table of Contents
# Target Audience
- :white_check_mark: For people who are more inclined to reject unknown calls.
- For those who need to answer unknown calls, for example, salesmen or lawyers, etc:
- :white_check_mark: If your carrier supports STIR/SHAKEN attestation, or there is any public spam database for your country.
- :white_check_mark: If your carrier supports STIR/SHAKEN attestation, or there is any public spam database available for your country.
- :x: Otherwise, consider using a blocker that has its own proprietary spam database.

# How it works
Expand Down Expand Up @@ -56,21 +56,22 @@ It works without replacing your default Call/SMS app.

# Permissions

| Permission (all optional) | Why |
|---------------------------|---------------------------------------------------------------------------------|
| INTERNET | For downloading spam numbers from public databases |
| ANSWER_PHONE_CALLS | Reject, Answer and Hang-up calls |
| POST_NOTIFICATIONS | Show notifications |
| READ_CONTACTS | For matching contacts |
| RECEIVE_SMS | For receiving new messages |
| READ_CALL_LOG<br>READ_SMS | For feature: Repeated Call/Dialed (check if it's repeated) |
| PACKAGE_USAGE_STATS | For feature: Recent Apps <br>For checking whether an app has been used recently |
| READ_PHONE_STATE | For block mode: Answer + Hang-up (monitor ringing state) |
| Permission (all optional) | Why |
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| INTERNET | For downloading spam numbers from public databases |
| MANAGE_EXTERNAL_STORAGE (Android 11+)<br>READ/WRITE_EXTERNAL_STORAGE (Android 10) | For file access from automated workflow |
| ANSWER_PHONE_CALLS | Reject, Answer and Hang-up calls |
| POST_NOTIFICATIONS | Show notifications |
| READ_CONTACTS | For matching contacts |
| RECEIVE_SMS | For receiving new messages |
| READ_CALL_LOG<br>READ_SMS | For checking if a call is repeated |
| PACKAGE_USAGE_STATS | For feature: Recent Apps <br>For checking whether an app has been used recently |
| READ_PHONE_STATE | For block mode: Answer + Hang-up (monitor ringing state) |

# Privacy
No data collection
- Internet access is only used for downloading spam numbers, if you don't use this feature, you can [disable the internet access](https://github.com/aj3423/SpamBlocker/issues/147).
- No external storage access, only accessible to scoped storage(the Downloads folder).
- Internet access:
- It's only used for downloading spam numbers, if you don't use this feature, you can [disable the internet access](https://github.com/aj3423/SpamBlocker/issues/147).
- No communication with other app
- [Reproducible](https://f-droid.org/docs/Reproducible_Builds/) apk

Expand All @@ -80,8 +81,8 @@ It works without replacing your default Call/SMS app.

# FAQ
- [Google shows security warning when installing this app](https://github.com/aj3423/SpamBlocker/issues/108)
- [Any feature stops working after app is killed](https://github.com/aj3423/SpamBlocker/issues/100)
- [How to always block particular number regardless of how many times it repeats, or within OffTime, etc...](https://github.com/aj3423/SpamBlocker/issues/80#issuecomment-2176943329)
- [Any feature stops working after the app is killed](https://github.com/aj3423/SpamBlocker/issues/100)
- [How to always block a particular number regardless of how many times it repeats, or within OffTime, etc...](https://github.com/aj3423/SpamBlocker/issues/80#issuecomment-2176943329)
- [Android 9- support](https://github.com/aj3423/SpamBlocker/issues/38)
- [Dual SIM support](https://github.com/aj3423/SpamBlocker/issues/72#issuecomment-2158981192)

Expand Down
12 changes: 6 additions & 6 deletions app/src/androidTest/java/spam/blocker/service/RuleTest.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package spam.blocker.service

//import androidx.test.core.app.ApplicationProvider
//import junit.framework.TestCase.assertEquals
//import org.junit.After
//import org.junit.Before
//import org.junit.Test
import android.content.Context
import androidx.test.core.app.ApplicationProvider
//import androidx.test.core.app.ApplicationProvider
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.mockkObject
import junit.framework.TestCase.assertEquals
import org.junit.After
import org.junit.Before
import org.junit.Test
//import junit.framework.TestCase.assertEquals
//import org.junit.After
//import org.junit.Before
//import org.junit.Test
import spam.blocker.db.ContentRuleTable
import spam.blocker.db.NumberRuleTable
import spam.blocker.db.RegexRule
import spam.blocker.def.Def
import spam.blocker.util.ContactInfo
import spam.blocker.util.Contacts
import spam.blocker.util.Now
import spam.blocker.util.Permissions
import spam.blocker.util.SharedPref.Contact
import spam.blocker.util.SharedPref.Dialed
Expand All @@ -28,7 +29,6 @@ import spam.blocker.util.SharedPref.RecentAppInfo
import spam.blocker.util.SharedPref.RecentApps
import spam.blocker.util.SharedPref.RepeatedCall
import spam.blocker.util.SharedPref.SharedPref
import spam.blocker.util.Now
import spam.blocker.util.Util
import java.util.Calendar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import org.junit.Test
import spam.blocker.service.bot.Daily
import spam.blocker.service.bot.Time
import spam.blocker.service.bot.Weekly
import java.time.DayOfWeek.THURSDAY
import java.time.DayOfWeek.TUESDAY
import java.time.DayOfWeek.WEDNESDAY
import java.time.DayOfWeek.THURSDAY
import java.time.Duration
import java.time.LocalDateTime

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/spam/blocker/db/BotTable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import android.content.Context
import androidx.core.database.getIntOrNull
import androidx.core.database.getStringOrNull
import kotlinx.serialization.Serializable
import spam.blocker.service.bot.CleanupSpamDB
import spam.blocker.service.bot.Daily
import spam.blocker.service.bot.IAction
import spam.blocker.service.bot.ISchedule
import spam.blocker.service.bot.MyWorkManager
import spam.blocker.service.bot.parseActions
import spam.blocker.service.bot.parseSchedule
import spam.blocker.service.bot.serialize
import spam.blocker.util.SharedPref.SpamDB
import java.util.UUID

@Serializable
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/spam/blocker/db/SpamTable.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package spam.blocker.db

import android.annotation.SuppressLint
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import androidx.core.database.getIntOrNull
import androidx.core.database.getStringOrNull
import kotlinx.serialization.Serializable
import spam.blocker.def.Def
import spam.blocker.util.Util
import spam.blocker.util.hasFlag
import spam.blocker.util.loge

@Serializable
data class SpamNumber(
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/spam/blocker/service/Checker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import spam.blocker.db.RuleTable
import spam.blocker.db.SmsTable
import spam.blocker.db.SpamTable
import spam.blocker.def.Def
import spam.blocker.ui.setting.quick.SpamDB
import spam.blocker.util.Contacts
import spam.blocker.util.Permissions
import spam.blocker.util.TimeSchedule
import spam.blocker.util.SharedPref.Contact
import spam.blocker.util.SharedPref.Dialed
import spam.blocker.util.SharedPref.RecentApps
import spam.blocker.util.SharedPref.RepeatedCall
import spam.blocker.util.SharedPref.SpamDB
import spam.blocker.util.SharedPref.Stir
import spam.blocker.util.TimeSchedule
import spam.blocker.util.Util
import spam.blocker.util.hasFlag

Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/spam/blocker/service/bot/Action.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import spam.blocker.util.IntentPermission
import spam.blocker.util.Lambda1
import spam.blocker.util.NormalPermission
import spam.blocker.util.Permissions
import java.lang.Exception

// When adding a new IAction type, follow all the steps:
// - add to `ActionType`
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/spam/blocker/service/bot/Actions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Context
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import kotlinx.coroutines.DelicateCoroutinesApi
Expand Down Expand Up @@ -44,7 +43,6 @@ import spam.blocker.util.logi
import spam.blocker.util.resolvePathTags
import spam.blocker.util.resolveTimeTags
import spam.blocker.util.toStringMap
import java.lang.Exception
import java.net.HttpURLConnection
import java.net.URL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package spam.blocker.service.bot

import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonBuilder
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic
import kotlinx.serialization.modules.subclass
Expand Down
33 changes: 10 additions & 23 deletions app/src/main/java/spam/blocker/service/bot/Schedule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,32 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TimeInput
import androidx.compose.material3.rememberTimePickerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.runtime.toMutableStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import kotlinx.serialization.PolymorphicSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import java.time.DayOfWeek.MONDAY
import java.time.DayOfWeek.TUESDAY
import java.time.DayOfWeek.WEDNESDAY
import java.time.DayOfWeek.THURSDAY
import java.time.DayOfWeek.FRIDAY
import java.time.DayOfWeek.SATURDAY
import java.time.DayOfWeek.SUNDAY
import java.time.Duration
import java.time.LocalDateTime
import java.time.temporal.TemporalAdjusters
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic
import kotlinx.serialization.modules.subclass
import spam.blocker.R
import spam.blocker.ui.M
import spam.blocker.ui.rememberSaveableMutableStateListOf
import spam.blocker.ui.widgets.HourMinInput
import spam.blocker.ui.widgets.RowCenter
import spam.blocker.ui.widgets.WeekdayPicker2
import spam.blocker.util.LocalDateTimeMockk
import java.lang.Exception
import java.time.DayOfWeek
import java.time.DayOfWeek.FRIDAY
import java.time.DayOfWeek.MONDAY
import java.time.DayOfWeek.SATURDAY
import java.time.DayOfWeek.SUNDAY
import java.time.DayOfWeek.THURSDAY
import java.time.DayOfWeek.TUESDAY
import java.time.DayOfWeek.WEDNESDAY
import java.time.Duration
import java.time.LocalDateTime
import java.time.temporal.TemporalAdjusters

// When adding a new ISchedule type, follow all the steps:
// - add to `ScheduleType`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import spam.blocker.BuildConfig
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/spam/blocker/ui/history/HistoryList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import spam.blocker.db.historyTableForType
import spam.blocker.def.Def
import spam.blocker.ui.M
import spam.blocker.ui.setting.regex.RuleEditDialog
import spam.blocker.ui.theme.LocalPalette
import spam.blocker.ui.widgets.BgLaunchApp
import spam.blocker.ui.widgets.DropdownWrapper
import spam.blocker.ui.widgets.LabelItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import spam.blocker.db.CallTable
import spam.blocker.db.HistoryRecord
import spam.blocker.db.HistoryTable
import spam.blocker.db.SmsTable
import spam.blocker.util.SharedPref.Global
import spam.blocker.util.SharedPref.HistoryOptions

/*
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/java/spam/blocker/ui/main/Debug.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
package spam.blocker.ui.main

import android.content.Context
import android.net.Uri
import android.os.Environment
import android.util.Log
import androidx.core.content.FileProvider.getUriForFile
import spam.blocker.util.TAG
import spam.blocker.util.Xml
import spam.blocker.util.loge
import java.io.File
import java.security.AccessController.getContext


fun debug(ctx: Context) {
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/spam/blocker/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.ui.platform.LocalView
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import spam.blocker.BuildConfig
import spam.blocker.Events
import spam.blocker.G
import spam.blocker.R
import spam.blocker.db.SmsTable
Expand Down Expand Up @@ -63,9 +62,15 @@ class MainActivity : ComponentActivity() {

super.onCreate(savedInstanceState)

if (BuildConfig.DEBUG)
if (BuildConfig.DEBUG) {
debug(this)

// Detect resource leak
Class.forName("dalvik.system.CloseGuard")
.getMethod("setEnabled", Boolean::class.javaPrimitiveType)
.invoke(null, true)
}

val ctx = this
val spf = Global(ctx)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import spam.blocker.ui.widgets.Str
import spam.blocker.ui.widgets.StrokeButton
import spam.blocker.ui.widgets.SwitchBox
import spam.blocker.util.NormalPermission
import spam.blocker.util.PermissionChain
import spam.blocker.util.Permissions
import spam.blocker.util.SharedPref.Global
import spam.blocker.util.Util
Expand Down
25 changes: 0 additions & 25 deletions app/src/main/java/spam/blocker/ui/setting/bot/ActionCard.kt
Original file line number Diff line number Diff line change
@@ -1,48 +1,23 @@
package spam.blocker.ui.setting.bot

import android.app.NotificationManager
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import spam.blocker.R
import spam.blocker.def.Def
import spam.blocker.service.bot.IAction
import spam.blocker.ui.M
import spam.blocker.ui.setting.regex.DisableNestedScrolling
import spam.blocker.ui.theme.LightMagenta
import spam.blocker.ui.theme.LocalPalette
import spam.blocker.ui.widgets.GreyIcon
import spam.blocker.ui.widgets.OutlineCard
import spam.blocker.ui.widgets.ResIcon
import spam.blocker.ui.widgets.RowVCenterSpaced
import spam.blocker.ui.widgets.Str
import spam.blocker.util.Lambda
import spam.blocker.util.hasFlag


@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import spam.blocker.ui.theme.LocalPalette
import spam.blocker.ui.theme.SkyBlue
import spam.blocker.ui.theme.Teal200
import spam.blocker.ui.widgets.BalloonQuestionMark
import spam.blocker.ui.widgets.GreyLabel
import spam.blocker.ui.widgets.LabelItem
import spam.blocker.ui.widgets.MenuButton
import spam.blocker.ui.widgets.PopupDialog
Expand Down
Loading

0 comments on commit 79f912b

Please sign in to comment.