From b288cdd120645125459c219409bb78ff3f073d51 Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 14 Dec 2021 11:34:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9F=BA=E7=A1=80=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 ++- app/build.gradle.kts | 44 +++++++-- app/proguard-rules.pro | 5 +- .../ExampleInstrumentedTest.kt | 4 +- app/src/main/AndroidManifest.xml | 28 ++++-- .../{ad_closer => gkd}/IUserService.aidl | 2 +- app/src/main/java/li/songe/ad_closer/App.kt | 11 --- .../java/li/songe/ad_closer/MainActivity.kt | 72 -------------- .../java/li/songe/ad_closer/data/RuleGroup.kt | 11 --- app/src/main/java/li/songe/gkd/App.kt | 18 ++++ .../songe/{ad_closer => gkd}/EntryActivity.kt | 2 +- .../main/java/li/songe/gkd/MainActivity.kt | 44 +++++++++ app/src/main/java/li/songe/gkd/WebActivity.kt | 12 +++ .../li/songe/{ad_closer => gkd}/data/Rule.kt | 17 ++-- .../main/java/li/songe/gkd/db/AppDatabase.kt | 30 ++++++ app/src/main/java/li/songe/gkd/db/Rule.kt | 40 ++++++++ .../main/java/li/songe/gkd/db/RuleGroup.kt | 48 +++++++++ .../{ad_closer => gkd}/log/OperationRecord.kt | 5 +- .../service/GkdService.kt} | 97 ++++++------------- .../{ad_closer => gkd}/service/UserService.kt | 4 +- .../java/li/songe/gkd/ui/BottomNavItem.kt | 34 +++++++ app/src/main/java/li/songe/gkd/ui/Nav.kt | 81 ++++++++++++++++ .../java/li/songe/gkd/ui/page/NativePage.kt | 42 ++++++++ .../java/li/songe/gkd/ui/page/SettingsPage.kt | 62 ++++++++++++ .../li/songe/gkd/ui/page/StatisticsPage.kt | 9 ++ .../li/songe/gkd/ui/page/SubscriptionPage.kt | 9 ++ .../{ad_closer => gkd}/ui/theme/Color.kt | 2 +- .../{ad_closer => gkd}/ui/theme/Shape.kt | 2 +- .../{ad_closer => gkd}/ui/theme/Theme.kt | 2 +- .../songe/{ad_closer => gkd}/ui/theme/Type.kt | 2 +- .../util/AttributeSelector.kt | 8 +- .../{ad_closer => gkd}/util/Extension.kt | 19 +--- .../{ad_closer => gkd}/util/MatchRule.kt | 7 +- .../{ad_closer => gkd}/util/MatchUnit.kt | 5 +- .../{ad_closer => gkd}/util/RelationUnit.kt | 4 +- app/src/main/res/drawable/ic_app_2.xml | 6 ++ app/src/main/res/drawable/ic_apps.xml | 20 ++++ app/src/main/res/drawable/ic_chart_bar.xml | 11 +++ app/src/main/res/drawable/ic_cog.xml | 11 +++ app/src/main/res/drawable/ic_database_set.xml | 11 +++ app/src/main/res/drawable/ic_link.xml | 6 ++ app/src/main/res/values/strings.xml | 6 +- .../{ad_closer => gkd}/ExampleUnitTest.kt | 4 +- build.gradle.kts | 2 +- settings.gradle.kts | 2 +- 45 files changed, 630 insertions(+), 245 deletions(-) rename app/src/androidTest/java/li/songe/{ad_closer => gkd}/ExampleInstrumentedTest.kt (85%) rename app/src/main/aidl/li/songe/{ad_closer => gkd}/IUserService.aidl (88%) delete mode 100644 app/src/main/java/li/songe/ad_closer/App.kt delete mode 100644 app/src/main/java/li/songe/ad_closer/MainActivity.kt delete mode 100644 app/src/main/java/li/songe/ad_closer/data/RuleGroup.kt create mode 100644 app/src/main/java/li/songe/gkd/App.kt rename app/src/main/java/li/songe/{ad_closer => gkd}/EntryActivity.kt (92%) create mode 100644 app/src/main/java/li/songe/gkd/MainActivity.kt create mode 100644 app/src/main/java/li/songe/gkd/WebActivity.kt rename app/src/main/java/li/songe/{ad_closer => gkd}/data/Rule.kt (94%) create mode 100644 app/src/main/java/li/songe/gkd/db/AppDatabase.kt create mode 100644 app/src/main/java/li/songe/gkd/db/Rule.kt create mode 100644 app/src/main/java/li/songe/gkd/db/RuleGroup.kt rename app/src/main/java/li/songe/{ad_closer => gkd}/log/OperationRecord.kt (66%) rename app/src/main/java/li/songe/{ad_closer/service/AdCloserService.kt => gkd/service/GkdService.kt} (56%) rename app/src/main/java/li/songe/{ad_closer => gkd}/service/UserService.kt (70%) create mode 100644 app/src/main/java/li/songe/gkd/ui/BottomNavItem.kt create mode 100644 app/src/main/java/li/songe/gkd/ui/Nav.kt create mode 100644 app/src/main/java/li/songe/gkd/ui/page/NativePage.kt create mode 100644 app/src/main/java/li/songe/gkd/ui/page/SettingsPage.kt create mode 100644 app/src/main/java/li/songe/gkd/ui/page/StatisticsPage.kt create mode 100644 app/src/main/java/li/songe/gkd/ui/page/SubscriptionPage.kt rename app/src/main/java/li/songe/{ad_closer => gkd}/ui/theme/Color.kt (83%) rename app/src/main/java/li/songe/{ad_closer => gkd}/ui/theme/Shape.kt (88%) rename app/src/main/java/li/songe/{ad_closer => gkd}/ui/theme/Theme.kt (96%) rename app/src/main/java/li/songe/{ad_closer => gkd}/ui/theme/Type.kt (95%) rename app/src/main/java/li/songe/{ad_closer => gkd}/util/AttributeSelector.kt (96%) rename app/src/main/java/li/songe/{ad_closer => gkd}/util/Extension.kt (91%) rename app/src/main/java/li/songe/{ad_closer => gkd}/util/MatchRule.kt (82%) rename app/src/main/java/li/songe/{ad_closer => gkd}/util/MatchUnit.kt (85%) rename app/src/main/java/li/songe/{ad_closer => gkd}/util/RelationUnit.kt (93%) create mode 100644 app/src/main/res/drawable/ic_app_2.xml create mode 100644 app/src/main/res/drawable/ic_apps.xml create mode 100644 app/src/main/res/drawable/ic_chart_bar.xml create mode 100644 app/src/main/res/drawable/ic_cog.xml create mode 100644 app/src/main/res/drawable/ic_database_set.xml create mode 100644 app/src/main/res/drawable/ic_link.xml rename app/src/test/java/li/songe/{ad_closer => gkd}/ExampleUnitTest.kt (85%) diff --git a/README.md b/README.md index 049b2a7..6ed7f72 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -# AdCloser +# gkd -基于无障碍和自定义匹配规则的广告关闭app +搞快点,顾名思义,做快速点击,一款基于无障碍和自定义匹配规则的快速点击app -记录递归调用的次数, 根据统计次数考虑是否添加规则长度, 可减少匹配时间 +## feature + +- 跳过启动页面 +- 关闭app内部广告 +- 任意点击操作 +- 支持导入订阅链接 +- 支持浏览器直接跳转导入规则至app + +类似 uiautomatorviewer 的路径选取规则创建器 # Fix Bug diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4b47424..c08291f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.application") id("kotlin-android") + id("kotlin-kapt") } val composeVersion = "1.0.5" @@ -9,7 +10,7 @@ android { buildToolsVersion = "31.0.0" defaultConfig { - applicationId = "li.songe.ad_closer" + applicationId = "li.songe.gkd" minSdk = 26 targetSdk = 31 versionCode = 1 @@ -40,9 +41,11 @@ android { ) ) signingConfig = signingConfigs.getByName("release") + manifestPlaceholders["appName"] = "搞快点" } debug { applicationIdSuffix = ".debug" + manifestPlaceholders["appName"] = "搞快点-dev" } } compileOptions { @@ -66,29 +69,50 @@ android { } dependencies { - - implementation("androidx.core:core-ktx:1.7.0") +// normal implementation("androidx.appcompat:appcompat:1.4.0") implementation("com.google.android.material:material:1.4.0") + +// ktx + implementation("androidx.core:core-ktx:1.7.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") + +// compose implementation("androidx.compose.ui:ui:$composeVersion") implementation("androidx.compose.material:material:$composeVersion") implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") + debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion") + androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion") implementation("androidx.activity:activity-compose:1.4.0") + implementation("androidx.navigation:navigation-compose:2.4.0-beta02") + +// test testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.3") androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion") - debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion") // https://github.com/RikkaApps/Shizuku-API - val shizuku_version = "12.1.0" - implementation("dev.rikka.shizuku:api:$shizuku_version") - // Add this line if you want to support Shizuku - implementation("dev.rikka.shizuku:provider:$shizuku_version") + val shizukuVersion = "12.1.0" + implementation("dev.rikka.shizuku:api:$shizukuVersion") + implementation("dev.rikka.shizuku:provider:$shizukuVersion") // 工具集合类 // https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md implementation("com.blankj:utilcodex:1.30.6") +// https://developer.android.com/jetpack/compose/navigation + implementation("androidx.navigation:navigation-compose:2.4.0-beta02") + +// https://bugly.qq.com/docs/user-guide/instruction-manual-android/ + implementation("com.tencent.bugly:crashreport:4.0.0") + +// https://developer.android.google.cn/training/data-storage/room?hl=zh-cn + val roomVersion = "2.3.0" + implementation("androidx.room:room-runtime:$roomVersion") + kapt("androidx.room:room-compiler:$roomVersion") + implementation("androidx.room:room-ktx:$roomVersion") + + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation ("com.google.code.gson:gson:2.8.9") + } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..1519d12 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn com.tencent.bugly.** +-keep public class com.tencent.bugly.**{*;} diff --git a/app/src/androidTest/java/li/songe/ad_closer/ExampleInstrumentedTest.kt b/app/src/androidTest/java/li/songe/gkd/ExampleInstrumentedTest.kt similarity index 85% rename from app/src/androidTest/java/li/songe/ad_closer/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/li/songe/gkd/ExampleInstrumentedTest.kt index 3b271f3..4f110cb 100644 --- a/app/src/androidTest/java/li/songe/ad_closer/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/li/songe/gkd/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer +package li.songe.gkd import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -19,6 +19,6 @@ class ExampleInstrumentedTest { fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("li.songe.ad_closer", appContext.packageName) + assertEquals("li.songe.gkd", appContext.packageName) } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6348812..3b204a5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,27 +1,28 @@ + package="li.songe.gkd"> + + + @@ -30,9 +31,20 @@ + + + + + + diff --git a/app/src/main/aidl/li/songe/ad_closer/IUserService.aidl b/app/src/main/aidl/li/songe/gkd/IUserService.aidl similarity index 88% rename from app/src/main/aidl/li/songe/ad_closer/IUserService.aidl rename to app/src/main/aidl/li/songe/gkd/IUserService.aidl index 4495573..4ef361f 100644 --- a/app/src/main/aidl/li/songe/ad_closer/IUserService.aidl +++ b/app/src/main/aidl/li/songe/gkd/IUserService.aidl @@ -1,5 +1,5 @@ // IUserService.aidl -package li.songe.ad_closer; +package li.songe.gkd; interface IUserService { void destroy() = 16777114; // Destroy method defined by Shizuku server diff --git a/app/src/main/java/li/songe/ad_closer/App.kt b/app/src/main/java/li/songe/ad_closer/App.kt deleted file mode 100644 index d23f010..0000000 --- a/app/src/main/java/li/songe/ad_closer/App.kt +++ /dev/null @@ -1,11 +0,0 @@ -package li.songe.ad_closer - -import android.app.Application -import com.blankj.utilcode.util.LogUtils - -class App:Application() { - override fun onCreate() { - super.onCreate() - LogUtils.d("onCreate") - } -} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/MainActivity.kt b/app/src/main/java/li/songe/ad_closer/MainActivity.kt deleted file mode 100644 index 32ecbf9..0000000 --- a/app/src/main/java/li/songe/ad_closer/MainActivity.kt +++ /dev/null @@ -1,72 +0,0 @@ -package li.songe.ad_closer - -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.tooling.preview.Preview -import com.blankj.utilcode.util.LogUtils -import li.songe.ad_closer.ui.theme.AdCloserTheme -import rikka.shizuku.Shizuku -import rikka.shizuku.Shizuku.OnRequestPermissionResultListener -import android.content.pm.PackageManager - - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - AdCloserTheme { - // A surface container using the 'background' color from the theme - Surface(color = MaterialTheme.colors.background) { - Greeting("Android2") - } - } - LogUtils.d(this) - packageName - } -// Shizuku.addRequestPermissionResultListener { requestCode, grantResult -> -// LogUtils.d(requestCode, grantResult) -// } -// checkPermission(0) -// Shizuku.bindUserService() - - } - private fun checkPermission(code: Int): Boolean { - if (Shizuku.isPreV11()) { - // Pre-v11 is unsupported - return false - } - return when { - Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED -> { - // Granted - true - } - Shizuku.shouldShowRequestPermissionRationale() -> { - // Users choose "Deny and don't ask again" - false - } - else -> { - // Request the permission - Shizuku.requestPermission(code) - false - } - } - } -} - -@Composable -fun Greeting(name: String) { - Text(text = "Hello $name 4399") -} - -@Preview(showBackground = true) -@Composable -fun DefaultPreview() { - AdCloserTheme { - Greeting("React") - } -} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/data/RuleGroup.kt b/app/src/main/java/li/songe/ad_closer/data/RuleGroup.kt deleted file mode 100644 index 618462a..0000000 --- a/app/src/main/java/li/songe/ad_closer/data/RuleGroup.kt +++ /dev/null @@ -1,11 +0,0 @@ -package li.songe.ad_closer.data - - -data class RuleGroup( - val id: Long, - val description: String, - val packageName: String, - val className: String, - val ruleList: List -) -// 从网址导入时, 会显示 规则描述 目标应用 目标活动界面, 此界面可点击打开 diff --git a/app/src/main/java/li/songe/gkd/App.kt b/app/src/main/java/li/songe/gkd/App.kt new file mode 100644 index 0000000..5286b6d --- /dev/null +++ b/app/src/main/java/li/songe/gkd/App.kt @@ -0,0 +1,18 @@ +package li.songe.gkd + +import android.app.Application +import com.blankj.utilcode.util.LogUtils +import com.tencent.bugly.crashreport.CrashReport + +class App:Application() { + companion object{ + lateinit var context:Application + } + override fun onCreate() { + super.onCreate() + context = this + LogUtils.d("onCreate") + LogUtils.getConfig().isLog2FileSwitch = true + CrashReport.initCrashReport(applicationContext, "d0ce46b353", false); + } +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/EntryActivity.kt b/app/src/main/java/li/songe/gkd/EntryActivity.kt similarity index 92% rename from app/src/main/java/li/songe/ad_closer/EntryActivity.kt rename to app/src/main/java/li/songe/gkd/EntryActivity.kt index 6a96a16..a20d6fa 100644 --- a/app/src/main/java/li/songe/ad_closer/EntryActivity.kt +++ b/app/src/main/java/li/songe/gkd/EntryActivity.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer +package li.songe.gkd import android.content.Intent import android.os.Bundle diff --git a/app/src/main/java/li/songe/gkd/MainActivity.kt b/app/src/main/java/li/songe/gkd/MainActivity.kt new file mode 100644 index 0000000..ca1b3d6 --- /dev/null +++ b/app/src/main/java/li/songe/gkd/MainActivity.kt @@ -0,0 +1,44 @@ +package li.songe.gkd + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.ui.graphics.Color +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import androidx.navigation.compose.rememberNavController +import kotlinx.coroutines.launch +import li.songe.gkd.ui.BottomNavigationBar +import li.songe.gkd.ui.NavHostContainer +import li.songe.gkd.ui.theme.AdCloserTheme + + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + AdCloserTheme { + Surface(color = MaterialTheme.colors.background) { + Surface(color = Color.White) { + val navController = rememberNavController() + Scaffold( + bottomBar = { + BottomNavigationBar(navController = navController) + }, content = { padding -> + NavHostContainer(navController = navController, padding = padding) + } + ) + } + } + } + } + lifecycleScope.launch { + lifecycle.repeatOnLifecycle(Lifecycle.State.CREATED) { + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/gkd/WebActivity.kt b/app/src/main/java/li/songe/gkd/WebActivity.kt new file mode 100644 index 0000000..ab00c49 --- /dev/null +++ b/app/src/main/java/li/songe/gkd/WebActivity.kt @@ -0,0 +1,12 @@ +package li.songe.gkd + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.blankj.utilcode.util.LogUtils + +class WebActivity:AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + LogUtils.d(intent.data) + } +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/data/Rule.kt b/app/src/main/java/li/songe/gkd/data/Rule.kt similarity index 94% rename from app/src/main/java/li/songe/ad_closer/data/Rule.kt rename to app/src/main/java/li/songe/gkd/data/Rule.kt index b0dfa15..04755ad 100644 --- a/app/src/main/java/li/songe/ad_closer/data/Rule.kt +++ b/app/src/main/java/li/songe/gkd/data/Rule.kt @@ -1,17 +1,13 @@ -package li.songe.ad_closer.data +package li.songe.gkd.data data class Rule( val packageName: String, val className: String, - val selector: String + val selector: String, + val description: String = "", ) { companion object { val defaultRuleList = listOf( -// Rule( -// "com.zhihu.android", -// "com.zhihu.android.mix.activity.ContentMixProfileActivity", -// "View[text=查看详情] + View[text=×]" -// ), Rule( "com.zhihu.android", "com.zhihu.android.mix.activity.ContentMixProfileActivity", @@ -77,6 +73,11 @@ data class Rule( "com.baidu.tieba.tblauncher.MainTabActivity", "ImageView[id=com.baidu.tieba:id/float_layer_feedback_picture]" ), + Rule( + "com.baidu.tieba", + "com.baidu.tieba.pb.pb.main.PbActivity", + "ImageView[id=com.baidu.tieba:id/float_layer_feedback_picture]" + ), Rule( "com.baidu.tieba", "com.baidu.tieba.tblauncher.MainTabActivity", @@ -125,7 +126,7 @@ data class Rule( Rule( "com.tencent.mm", "com.tencent.mm.plugin.sns.ui.SnsTimeLineUI", - "LinearLayout[childCount=2] > LinearLayout[id=com.tencent.mm:id/fzb] > TextView[id=com.tencent.mm:id/fzg] + LinearLayout[id=com.tencent.mm:id/fj][childCount=0]" + "LinearLayout > LinearLayout[id=com.tencent.mm:id/fzb][childCount=2] > TextView[id=com.tencent.mm:id/fzg] + LinearLayout[id=com.tencent.mm:id/fj][childCount=0]" ), Rule( "com.baidu.tieba", diff --git a/app/src/main/java/li/songe/gkd/db/AppDatabase.kt b/app/src/main/java/li/songe/gkd/db/AppDatabase.kt new file mode 100644 index 0000000..120b49b --- /dev/null +++ b/app/src/main/java/li/songe/gkd/db/AppDatabase.kt @@ -0,0 +1,30 @@ +package li.songe.gkd.db + +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase +import li.songe.gkd.App + +@Database(entities = [Rule::class, RuleGroup::class], version = 1) +abstract class AppDatabase : RoomDatabase() { + abstract fun ruleDao(): RuleDao + abstract fun ruleGroupDao(): RuleGroupDao + + companion object { + val db by lazy { + var basePath = (App.context.getExternalFilesDir(null)?.absolutePath ?: "") + var name = "database.db" + if (basePath.isNotEmpty()) { + if (!basePath.endsWith("/")) { + basePath += "/" + } + name = basePath + name + } + Room.databaseBuilder( + App.context, + AppDatabase::class.java, + name + ).build() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/gkd/db/Rule.kt b/app/src/main/java/li/songe/gkd/db/Rule.kt new file mode 100644 index 0000000..12cbddd --- /dev/null +++ b/app/src/main/java/li/songe/gkd/db/Rule.kt @@ -0,0 +1,40 @@ +package li.songe.gkd.db + +import androidx.room.* +import kotlin.random.Random + + +@Entity(tableName = "rule") +data class Rule( + @PrimaryKey() @ColumnInfo(name = "id") val id: Long = Random.nextLong( + -9007199254740991L, + 9007199254740991L + ), + @ColumnInfo(name = "package_name") var packageName: String, + @ColumnInfo(name = "class_name") var className: String, + @ColumnInfo(name = "selector") var selector: String, + @ColumnInfo(name = "description") var description: String = "", + @ColumnInfo(name = "rule_group_id") var ruleGroupUid: Long, + @ColumnInfo(name = "ctime") var ctime: Long = System.currentTimeMillis(), + @ColumnInfo(name = "mtime") var mtime: Long = System.currentTimeMillis(), + @ColumnInfo(name = "disable") var disable: Boolean = false, + /** + * 规则序列号, 先匹配 seq 最小的规则, 如果序列号相等, 则执行顺序是未知的 + */ + @ColumnInfo(name = "seq") var seq: Int = 0, +) + +@Dao +interface RuleDao { + @Query("SELECT * FROM rule") + suspend fun query(): MutableList + + @Update + suspend fun update(vararg args: Rule) + + @Delete + suspend fun delete(vararg args: Rule) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insert(vararg args: Rule) +} diff --git a/app/src/main/java/li/songe/gkd/db/RuleGroup.kt b/app/src/main/java/li/songe/gkd/db/RuleGroup.kt new file mode 100644 index 0000000..e212043 --- /dev/null +++ b/app/src/main/java/li/songe/gkd/db/RuleGroup.kt @@ -0,0 +1,48 @@ +package li.songe.gkd.db + +import androidx.room.* +import kotlin.random.Random + + +@Entity(tableName = "rule_group") +data class RuleGroup( + @PrimaryKey() @ColumnInfo(name = "id") val id: Long = Random.nextLong( + -9007199254740991L, + 9007199254740991L + ), + @ColumnInfo(name = "package_name") var packageName: String, + @ColumnInfo(name = "class_name") var className: String, + @ColumnInfo(name = "description") var description: String = "", + @ColumnInfo(name = "ctime") var ctime: Long = System.currentTimeMillis(), + @ColumnInfo(name = "mtime") var mtime: Long = System.currentTimeMillis(), + @ColumnInfo(name = "disable") var disable: Boolean = false, +) + +data class RuleGroupWithRuleList( + @Embedded val ruleGroup: RuleGroup, + @Relation( + parentColumn = "id", + entityColumn = "rule_group_id" + ) + val ruleList: MutableList +) + +@Dao +interface RuleGroupDao { + @Query("SELECT * FROM rule_group") + suspend fun query(): MutableList + + @Update + suspend fun update(vararg args: RuleGroup) + + @Delete + suspend fun delete(vararg args: RuleGroup) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insert(vararg args: RuleGroup) + + @Transaction + @Query("SELECT * FROM rule_group") + suspend fun queryRuleGroupWithRuleList(): MutableList + +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/log/OperationRecord.kt b/app/src/main/java/li/songe/gkd/log/OperationRecord.kt similarity index 66% rename from app/src/main/java/li/songe/ad_closer/log/OperationRecord.kt rename to app/src/main/java/li/songe/gkd/log/OperationRecord.kt index 35b6a98..9db757a 100644 --- a/app/src/main/java/li/songe/ad_closer/log/OperationRecord.kt +++ b/app/src/main/java/li/songe/gkd/log/OperationRecord.kt @@ -1,7 +1,8 @@ -package li.songe.ad_closer.log +package li.songe.gkd.log data class OperationRecord( val timestamp: Long, val packageName: String, val classNme: String, - val ruleId: String) + val ruleId: String +) diff --git a/app/src/main/java/li/songe/ad_closer/service/AdCloserService.kt b/app/src/main/java/li/songe/gkd/service/GkdService.kt similarity index 56% rename from app/src/main/java/li/songe/ad_closer/service/AdCloserService.kt rename to app/src/main/java/li/songe/gkd/service/GkdService.kt index 6b7d68a..fd89872 100644 --- a/app/src/main/java/li/songe/ad_closer/service/AdCloserService.kt +++ b/app/src/main/java/li/songe/gkd/service/GkdService.kt @@ -1,28 +1,19 @@ -package li.songe.ad_closer.service +package li.songe.gkd.service import android.accessibilityservice.AccessibilityService import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityNodeInfo import com.blankj.utilcode.util.LogUtils import kotlinx.coroutines.* -import li.songe.ad_closer.data.Rule -import li.songe.ad_closer.util.MatchRule -import li.songe.ad_closer.util.findNodeInfo +import li.songe.gkd.data.Rule +import li.songe.gkd.util.MatchRule +import li.songe.gkd.util.findNodeInfo /** * demo: https://juejin.cn/post/6844903589127651335 */ -class AdCloserService : AccessibilityService() { - -// private fun getActivityInfo(componentName: ComponentName): ActivityInfo? { -// return try { -// packageManager.getActivityInfo(componentName, 0) -// } catch (e: NameNotFoundException) { -// null -// } -// } - +class GkdService : AccessibilityService() { private val scope = CoroutineScope(Dispatchers.Default + Job()) // override fun onDestroy() { // super.onDestroy() @@ -33,9 +24,11 @@ class AdCloserService : AccessibilityService() { LogUtils.d("onCreate") } + private var job: Job? = null override fun onServiceConnected() { super.onServiceConnected() - scope.launch { + LogUtils.d("onServiceConnected") + job = scope.launch { while (true) { if (!this.isActive) { break @@ -50,21 +43,23 @@ class AdCloserService : AccessibilityService() { if (window != null && ruleListMap.containsKey(currentActivityClassName)) { run loop@{ ruleListMap[currentActivityClassName]!!.forEachIndexed { _, rule -> - var nodeInfo = findNodeInfo(window, rule.matchUnit, listOf(0)) - var level = 0 - while (nodeInfo != null && !nodeInfo.isClickable) { - nodeInfo = nodeInfo.parent - level += 1 - } + val nodeInfo = findNodeInfo(window, rule.matchUnit, listOf(0)) if (nodeInfo != null) { - nodeInfo.apply { - LogUtils.dTag("click", level, rule.rawText) - performAction(AccessibilityNodeInfo.ACTION_CLICK) + LogUtils.dTag("findNode", nodeInfo) + var parentNodeInfo = nodeInfo + var level = 0 + while (parentNodeInfo != null && !parentNodeInfo.isClickable) { + parentNodeInfo = parentNodeInfo.parent + level += 1 + } + if (parentNodeInfo != null) { + parentNodeInfo.apply { + LogUtils.dTag("click", level, rule.rawText) + performAction(AccessibilityNodeInfo.ACTION_CLICK) + } + return@loop } - } else { - LogUtils.dTag("click", "not isClickable", rule.rawText) } - return@loop } } @@ -92,18 +87,11 @@ class AdCloserService : AccessibilityService() { } override fun onAccessibilityEvent(event: AccessibilityEvent?) { - if (event == null) { + if (event == null || event.className == null) { return } when (event.eventType) { AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED -> { -// LogUtils.d(rootInActiveWindow?.packageName, event.packageName, event.className) -// if (event.packageName == rootInActiveWindow?.packageName && event.className != null && event.className.startsWith( -// event.packageName -// ) -// ) { -// -// } val className = event.className.toString() // val packageName = event.packageName.toString() // 在桌面和应用之间来回切换, 大概率导致识别失败 @@ -120,30 +108,6 @@ class AdCloserService : AccessibilityService() { else -> { } } -// val componentName = -// ComponentName( -// event.packageName?.toString() ?: "", -// event.className?.toString() ?: "" -// ) -// val activityInfo = getActivityInfo(componentName) -// if (activityInfo != null) { -// val newClassName = event.className.toString() -// if (currentActivityClassName != newClassName) { -// currentActivityClassName = newClassName -//// LogUtils.dTag("newClassName", newClassName, rootInActiveWindow?.packageName) -// } -// } -// when (event.eventType) { -// AccessibilityEvent.TYPE_WINDOWS_CHANGED -> { -// } -// AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED -> { -// } -// AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED -> { -// -// } -// else -> { -// } -// } } private var currentActivityClassName = "" @@ -160,16 +124,15 @@ class AdCloserService : AccessibilityService() { } override fun onInterrupt() { - scope.cancel() -// val invok = {a: Int, b: Int->a+b} + job?.cancel() + LogUtils.d("onInterrupt") } + override fun onDestroy() { + super.onDestroy() + scope.cancel() + LogUtils.d("onDestroy") + } } -//typealias Test = (a: Int, b: Int) -> Int -//typealias Test = (a: Int, ) -> Int - -//fun invok(a: Int, b: Int = 0){ -// -//} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/service/UserService.kt b/app/src/main/java/li/songe/gkd/service/UserService.kt similarity index 70% rename from app/src/main/java/li/songe/ad_closer/service/UserService.kt rename to app/src/main/java/li/songe/gkd/service/UserService.kt index 1f65119..92ea1b8 100644 --- a/app/src/main/java/li/songe/ad_closer/service/UserService.kt +++ b/app/src/main/java/li/songe/gkd/service/UserService.kt @@ -1,6 +1,6 @@ -package li.songe.ad_closer.service +package li.songe.gkd.service -import li.songe.ad_closer.IUserService +import li.songe.gkd.IUserService class UserService: IUserService.Stub() { override fun destroy() { diff --git a/app/src/main/java/li/songe/gkd/ui/BottomNavItem.kt b/app/src/main/java/li/songe/gkd/ui/BottomNavItem.kt new file mode 100644 index 0000000..0894aca --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/BottomNavItem.kt @@ -0,0 +1,34 @@ +package li.songe.gkd.ui + +import androidx.annotation.DrawableRes +import li.songe.gkd.R + +data class BottomNavItem( + val label: String, + @DrawableRes + val icon: Int, + val route: String, +) + +val BottomNavItems = listOf( + BottomNavItem( + label = "统计", + icon = R.drawable.ic_chart_bar, + route = "statistics" + ), + BottomNavItem( + label = "本地", + icon = R.drawable.ic_database_set, + route = "native" + ), + BottomNavItem( + label = "订阅", + icon = R.drawable.ic_link, + route = "subscription" + ), + BottomNavItem( + label = "设置", + icon = R.drawable.ic_cog, + route = "settings" + ), +) \ No newline at end of file diff --git a/app/src/main/java/li/songe/gkd/ui/Nav.kt b/app/src/main/java/li/songe/gkd/ui/Nav.kt new file mode 100644 index 0000000..d878ddc --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/Nav.kt @@ -0,0 +1,81 @@ +package li.songe.gkd.ui + +import androidx.compose.foundation.layout.* +import androidx.compose.material.BottomNavigation +import androidx.compose.material.BottomNavigationItem +import androidx.compose.material.Icon +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.currentBackStackEntryAsState +import li.songe.gkd.ui.page.NativePage +import li.songe.gkd.ui.page.SettingsPage +import li.songe.gkd.ui.page.StatisticsPage +import li.songe.gkd.ui.page.SubscriptionPage + + +@Composable +fun NavHostContainer( + navController: NavHostController, + padding: PaddingValues +) { + NavHost( + navController = navController, + startDestination = "statistics", + modifier = Modifier.padding(paddingValues = padding), + builder = { + composable("native") { + NativePage() + } + composable("settings") { + SettingsPage() + } + composable("statistics") { + StatisticsPage() + } + composable("subscription") { + SubscriptionPage() + } + } + ) +} + +@Composable +fun BottomNavigationBar(navController: NavController) { + BottomNavigation( + backgroundColor = Color.White, + ) { + val navBackStackEntry by navController.currentBackStackEntryAsState() + val currentRoute = navBackStackEntry?.destination?.route + LaunchedEffect(Unit){ + navController.navigate(BottomNavItems[1].route) + } + BottomNavItems.forEach { navItem -> + BottomNavigationItem( + selected = currentRoute == navItem.route, + onClick = { + navController.navigate(navItem.route) + }, + icon = { + Icon( + painter = painterResource(id = navItem.icon), + contentDescription = navItem.label, + modifier = Modifier.padding(2.dp) + ) + }, + label = { + Text(text = navItem.label) + } + ) + } + } +} diff --git a/app/src/main/java/li/songe/gkd/ui/page/NativePage.kt b/app/src/main/java/li/songe/gkd/ui/page/NativePage.kt new file mode 100644 index 0000000..7177876 --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/page/NativePage.kt @@ -0,0 +1,42 @@ +package li.songe.gkd.ui.page + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.Switch +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import li.songe.gkd.R + +@Composable +fun NativePage() { + Column { + Row( + modifier = Modifier.height(40.dp) + ) { + Image( + painter = painterResource(R.drawable.ic_app_2), + contentDescription = "", + modifier = Modifier + .fillMaxHeight() + .clip(CircleShape) + ) + Column { + Text(text = "应用名称") + Text(text = "8/10") + } + val checkedState = remember { mutableStateOf(true) } + Switch(checked = checkedState.value, + onCheckedChange = { + checkedState.value = it + } + ) + } + } +} diff --git a/app/src/main/java/li/songe/gkd/ui/page/SettingsPage.kt b/app/src/main/java/li/songe/gkd/ui/page/SettingsPage.kt new file mode 100644 index 0000000..f24bf3d --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/page/SettingsPage.kt @@ -0,0 +1,62 @@ +package li.songe.gkd.ui.page + +import androidx.compose.animation.animateColorAsState +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Switch +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp + +@Composable +fun SettingsPage() { + Column( + modifier = Modifier + .verticalScroll( + state = rememberScrollState() + ) + .padding(20.dp) + ) { + Row { + val checkedState = remember { mutableStateOf(true) } + val animatedColor = animateColorAsState( + Color( + 0, + 0, + 0, + (0xFF * (if (checkedState.value) 1f else .3f)).toInt() + ) + ) + Text( + text = "服务已${(if (checkedState.value) "开启" else "关闭")}", + color = animatedColor.value + ) + Switch(checked = checkedState.value, + onCheckedChange = { + checkedState.value = it + } + ) + } + Row { + val checkedState = remember { mutableStateOf(true) } + Text(text = "在[最近任务]界面中隐藏本应用") + Switch(checked = checkedState.value, + onCheckedChange = { checkedState.value = it } + ) + } + Row { + val checkedState = remember { mutableStateOf(true) } + Text(text = "通知栏显示") + Switch(checked = checkedState.value, + onCheckedChange = { checkedState.value = it } + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/gkd/ui/page/StatisticsPage.kt b/app/src/main/java/li/songe/gkd/ui/page/StatisticsPage.kt new file mode 100644 index 0000000..1395ce6 --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/page/StatisticsPage.kt @@ -0,0 +1,9 @@ +package li.songe.gkd.ui.page + +import androidx.compose.material.Text +import androidx.compose.runtime.Composable + +@Composable +fun StatisticsPage(){ + Text(text = "Statistics") +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/gkd/ui/page/SubscriptionPage.kt b/app/src/main/java/li/songe/gkd/ui/page/SubscriptionPage.kt new file mode 100644 index 0000000..8aae5ee --- /dev/null +++ b/app/src/main/java/li/songe/gkd/ui/page/SubscriptionPage.kt @@ -0,0 +1,9 @@ +package li.songe.gkd.ui.page + +import androidx.compose.material.Text +import androidx.compose.runtime.Composable + +@Composable +fun SubscriptionPage(){ + Text(text = "Subscription") +} \ No newline at end of file diff --git a/app/src/main/java/li/songe/ad_closer/ui/theme/Color.kt b/app/src/main/java/li/songe/gkd/ui/theme/Color.kt similarity index 83% rename from app/src/main/java/li/songe/ad_closer/ui/theme/Color.kt rename to app/src/main/java/li/songe/gkd/ui/theme/Color.kt index 0211bd5..4991555 100644 --- a/app/src/main/java/li/songe/ad_closer/ui/theme/Color.kt +++ b/app/src/main/java/li/songe/gkd/ui/theme/Color.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.ui.theme +package li.songe.gkd.ui.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/java/li/songe/ad_closer/ui/theme/Shape.kt b/app/src/main/java/li/songe/gkd/ui/theme/Shape.kt similarity index 88% rename from app/src/main/java/li/songe/ad_closer/ui/theme/Shape.kt rename to app/src/main/java/li/songe/gkd/ui/theme/Shape.kt index 0912a14..88c9127 100644 --- a/app/src/main/java/li/songe/ad_closer/ui/theme/Shape.kt +++ b/app/src/main/java/li/songe/gkd/ui/theme/Shape.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.ui.theme +package li.songe.gkd.ui.theme import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Shapes diff --git a/app/src/main/java/li/songe/ad_closer/ui/theme/Theme.kt b/app/src/main/java/li/songe/gkd/ui/theme/Theme.kt similarity index 96% rename from app/src/main/java/li/songe/ad_closer/ui/theme/Theme.kt rename to app/src/main/java/li/songe/gkd/ui/theme/Theme.kt index e4e6235..d230e09 100644 --- a/app/src/main/java/li/songe/ad_closer/ui/theme/Theme.kt +++ b/app/src/main/java/li/songe/gkd/ui/theme/Theme.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.ui.theme +package li.songe.gkd.ui.theme import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material.MaterialTheme diff --git a/app/src/main/java/li/songe/ad_closer/ui/theme/Type.kt b/app/src/main/java/li/songe/gkd/ui/theme/Type.kt similarity index 95% rename from app/src/main/java/li/songe/ad_closer/ui/theme/Type.kt rename to app/src/main/java/li/songe/gkd/ui/theme/Type.kt index 4a44331..73f370e 100644 --- a/app/src/main/java/li/songe/ad_closer/ui/theme/Type.kt +++ b/app/src/main/java/li/songe/gkd/ui/theme/Type.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.ui.theme +package li.songe.gkd.ui.theme import androidx.compose.material.Typography import androidx.compose.ui.text.TextStyle diff --git a/app/src/main/java/li/songe/ad_closer/util/AttributeSelector.kt b/app/src/main/java/li/songe/gkd/util/AttributeSelector.kt similarity index 96% rename from app/src/main/java/li/songe/ad_closer/util/AttributeSelector.kt rename to app/src/main/java/li/songe/gkd/util/AttributeSelector.kt index 360ca6d..6eb255d 100644 --- a/app/src/main/java/li/songe/ad_closer/util/AttributeSelector.kt +++ b/app/src/main/java/li/songe/gkd/util/AttributeSelector.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.util +package li.songe.gkd.util import java.lang.Error import java.util.* @@ -20,7 +20,6 @@ data class AttributeSelector(val attr: Attribute, val operator: Operator, val va Less -> "<" More -> ">" Start -> "^" - else-> TODO() } + "=" } } @@ -35,7 +34,6 @@ data class AttributeSelector(val attr: Attribute, val operator: Operator, val va ChildCount -> "childCount" Id -> "id" Text -> "text" - else -> TODO() } } } @@ -107,7 +105,7 @@ data class AttributeSelector(val attr: Attribute, val operator: Operator, val va fun parseMulti(text: String): List { var startIndex = -1 - var endIndex = -1 + var endIndex: Int val attrRawList = mutableListOf() text.forEachIndexed { index, c -> when (c) { @@ -131,7 +129,6 @@ data class AttributeSelector(val attr: Attribute, val operator: Operator, val va Attribute.ChildCount -> "childCount" Attribute.Id -> "id" Attribute.Text -> "text" - else-> TODO() } val operator = (when (selector.operator) { Operator.End -> "$" @@ -140,7 +137,6 @@ data class AttributeSelector(val attr: Attribute, val operator: Operator, val va Operator.Less -> "<" Operator.More -> ">" Operator.Start -> "^" - else-> TODO() }) return "[$attr$operator=${selector.value}]" } diff --git a/app/src/main/java/li/songe/ad_closer/util/Extension.kt b/app/src/main/java/li/songe/gkd/util/Extension.kt similarity index 91% rename from app/src/main/java/li/songe/ad_closer/util/Extension.kt rename to app/src/main/java/li/songe/gkd/util/Extension.kt index 59bcf59..ab17dfe 100644 --- a/app/src/main/java/li/songe/ad_closer/util/Extension.kt +++ b/app/src/main/java/li/songe/gkd/util/Extension.kt @@ -1,8 +1,6 @@ -package li.songe.ad_closer.util +package li.songe.gkd.util -import android.graphics.Rect import android.view.accessibility.AccessibilityNodeInfo -import com.blankj.utilcode.util.LogUtils /** * @param pathIndexList 当前节点在节点树的路径, 最后一项代表节点是父节点第几个元素, 第一项是 0 @@ -49,7 +47,6 @@ private fun match( AttributeSelector.Operator.Less -> childCount < it.value.toInt() AttributeSelector.Operator.More -> childCount > it.value.toInt() AttributeSelector.Operator.Start -> false - else -> TODO() } AttributeSelector.Attribute.Id -> { when (it.operator) { @@ -59,7 +56,6 @@ private fun match( AttributeSelector.Operator.Less -> false AttributeSelector.Operator.More -> false AttributeSelector.Operator.Start -> false - else -> TODO() } } AttributeSelector.Attribute.Text -> text != null && when (it.operator) { @@ -69,9 +65,7 @@ private fun match( AttributeSelector.Operator.Less -> false AttributeSelector.Operator.More -> false AttributeSelector.Operator.Start -> text.startsWith(it.value) - else -> TODO() } - else -> TODO() } } if (!condition2) { @@ -147,17 +141,6 @@ fun findNodeInfo( return nodeInfo1 } -//inline fun AccessibilityNodeInfo.forEach(action: (AccessibilityNodeInfo) -> Unit): Unit { -// var index = 0 -// while (index < childCount) { -// val child: AccessibilityNodeInfo? = getChild(index) -// if (child != null) { -// action(child) -// } -// index += 1 -// } -//} - inline fun AccessibilityNodeInfo.forEachIndexed(action: (index: Int, AccessibilityNodeInfo) -> Unit) { var index = 0 while (index < childCount) { diff --git a/app/src/main/java/li/songe/ad_closer/util/MatchRule.kt b/app/src/main/java/li/songe/gkd/util/MatchRule.kt similarity index 82% rename from app/src/main/java/li/songe/ad_closer/util/MatchRule.kt rename to app/src/main/java/li/songe/gkd/util/MatchRule.kt index 23f6a74..c15b062 100644 --- a/app/src/main/java/li/songe/ad_closer/util/MatchRule.kt +++ b/app/src/main/java/li/songe/gkd/util/MatchRule.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.util +package li.songe.gkd.util data class MatchRule(val matchUnit: MatchUnit, val rawText: String) { companion object { @@ -29,11 +29,6 @@ data class MatchRule(val matchUnit: MatchUnit, val rawText: String) { return selector.rawText } } - -// sealed class RuleUnit(open val data: T) -// class MatchRuleUnit(override val data: MatchUnit) : RuleUnit(data) -// class RelationRuleUnit(override val data: RelationUnit) : RuleUnit(data) - } /** diff --git a/app/src/main/java/li/songe/ad_closer/util/MatchUnit.kt b/app/src/main/java/li/songe/gkd/util/MatchUnit.kt similarity index 85% rename from app/src/main/java/li/songe/ad_closer/util/MatchUnit.kt rename to app/src/main/java/li/songe/gkd/util/MatchUnit.kt index 2d7414c..6953639 100644 --- a/app/src/main/java/li/songe/ad_closer/util/MatchUnit.kt +++ b/app/src/main/java/li/songe/gkd/util/MatchUnit.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.util +package li.songe.gkd.util data class MatchUnit( val className: String, @@ -19,9 +19,6 @@ data class MatchUnit( } } } -// if (markIndex <= 0) { -// throw Error("markIndex: expect it>0, got $markIndex") -// } val className = sb.toString() return MatchUnit( diff --git a/app/src/main/java/li/songe/ad_closer/util/RelationUnit.kt b/app/src/main/java/li/songe/gkd/util/RelationUnit.kt similarity index 93% rename from app/src/main/java/li/songe/ad_closer/util/RelationUnit.kt rename to app/src/main/java/li/songe/gkd/util/RelationUnit.kt index 9d53e17..b9c31a9 100644 --- a/app/src/main/java/li/songe/ad_closer/util/RelationUnit.kt +++ b/app/src/main/java/li/songe/gkd/util/RelationUnit.kt @@ -1,4 +1,4 @@ -package li.songe.ad_closer.util +package li.songe.gkd.util data class RelationUnit(val to: MatchUnit, val operator: Operator) { sealed class Operator { @@ -14,6 +14,7 @@ data class RelationUnit(val to: MatchUnit, val operator: Operator) { return offset.toString() } Parent -> ">" + else -> throw NotImplementedError() } } } @@ -57,6 +58,7 @@ data class RelationUnit(val to: MatchUnit, val operator: Operator) { throw Error("operator.offset: expect no-zero, got 0") } } + else -> throw NotImplementedError() } } } diff --git a/app/src/main/res/drawable/ic_app_2.xml b/app/src/main/res/drawable/ic_app_2.xml new file mode 100644 index 0000000..32a55fb --- /dev/null +++ b/app/src/main/res/drawable/ic_app_2.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ic_apps.xml b/app/src/main/res/drawable/ic_apps.xml new file mode 100644 index 0000000..c06169d --- /dev/null +++ b/app/src/main/res/drawable/ic_apps.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_chart_bar.xml b/app/src/main/res/drawable/ic_chart_bar.xml new file mode 100644 index 0000000..ea9d940 --- /dev/null +++ b/app/src/main/res/drawable/ic_chart_bar.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/res/drawable/ic_cog.xml b/app/src/main/res/drawable/ic_cog.xml new file mode 100644 index 0000000..c4d0510 --- /dev/null +++ b/app/src/main/res/drawable/ic_cog.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/res/drawable/ic_database_set.xml b/app/src/main/res/drawable/ic_database_set.xml new file mode 100644 index 0000000..585a03b --- /dev/null +++ b/app/src/main/res/drawable/ic_database_set.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/res/drawable/ic_link.xml b/app/src/main/res/drawable/ic_link.xml new file mode 100644 index 0000000..c9ef478 --- /dev/null +++ b/app/src/main/res/drawable/ic_link.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4fb74aa..b6e4989 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - AdCloser - accessibility_service_label - accessibility_service_description + 搞快点 + 搞快点 + 基于规则匹配的无障碍速点服务 \ No newline at end of file diff --git a/app/src/test/java/li/songe/ad_closer/ExampleUnitTest.kt b/app/src/test/java/li/songe/gkd/ExampleUnitTest.kt similarity index 85% rename from app/src/test/java/li/songe/ad_closer/ExampleUnitTest.kt rename to app/src/test/java/li/songe/gkd/ExampleUnitTest.kt index 8e51523..966d6c6 100644 --- a/app/src/test/java/li/songe/ad_closer/ExampleUnitTest.kt +++ b/app/src/test/java/li/songe/gkd/ExampleUnitTest.kt @@ -1,6 +1,6 @@ -package li.songe.ad_closer +package li.songe.gkd -import li.songe.ad_closer.util.MatchRule +import li.songe.gkd.util.MatchRule import org.junit.Test import org.junit.Assert.* diff --git a/build.gradle.kts b/build.gradle.kts index 736298a..7fe2be7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ buildscript { } dependencies { val kotlinVersion= "1.5.31" - classpath("com.android.tools.build:gradle:7.0.3") + classpath("com.android.tools.build:gradle:7.0.4") classpath(kotlin("gradle-plugin", version = kotlinVersion)) // NOTE: Do not place your application dependencies here; they belong diff --git a/settings.gradle.kts b/settings.gradle.kts index c9dd689..ef59505 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,5 +5,5 @@ dependencyResolutionManagement { mavenCentral() } } -rootProject.name = "AdCloser" +rootProject.name = "gkd" include(":app")