diff --git a/.gitignore b/.gitignore index aa724b7..01684f2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ .externalNativeBuild .cxx local.properties +app/release diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 8e6d21a..7799d53 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,16 @@ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 69e8615..8d81632 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 40c82cb..3b798c2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6eb574e..28c4d9e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,27 +1,35 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") + id("dev.rikka.tools.refine") } android { namespace = "com.qhy040404.fxxkmiuiad" - compileSdk = 33 + compileSdk = 34 defaultConfig { applicationId = "com.qhy040404.fxxkmiuiad" minSdk = 29 - targetSdk = 33 + targetSdk = 34 versionCode = 3 versionName = "1.1.1" } + buildFeatures { + buildConfig = true + viewBinding = true + } + buildTypes { release { isMinifyEnabled = true isShrinkResources = true isCrunchPngs = true - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) packagingOptions.resources.excludes += setOf( "DebugProbesKt.bin", "META-INF/*.version" @@ -38,9 +46,18 @@ android { } } +configurations.all { + exclude("androidx.appcompat", "appcompat") + exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7") +} + dependencies { - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("com.google.android.material:material:1.8.0") - implementation("dev.rikka.shizuku:api:13.1.0") - implementation("dev.rikka.shizuku:provider:13.1.0") + compileOnly(project(":hidden-api")) + + implementation("androidx.annotation:annotation:1.7.1") + implementation("com.google.android.material:material:1.11.0") + implementation("dev.rikka.rikkax.appcompat:appcompat:1.6.1") + implementation("dev.rikka.shizuku:api:13.1.5") + implementation("dev.rikka.shizuku:provider:13.1.5") + implementation("dev.rikka.tools.refine:runtime:4.4.0") } \ No newline at end of file diff --git a/app/src/main/java/com/qhy040404/fxxkmiuiad/Constants.kt b/app/src/main/java/com/qhy040404/fxxkmiuiad/Constants.kt index 6a0c559..c1c6fc5 100644 --- a/app/src/main/java/com/qhy040404/fxxkmiuiad/Constants.kt +++ b/app/src/main/java/com/qhy040404/fxxkmiuiad/Constants.kt @@ -1,12 +1,12 @@ package com.qhy040404.fxxkmiuiad object Constants { - const val shizuku = "moe.shizuku.privileged.api" - const val hybrid = "com.miui.hybrid" - const val ad = "com.miui.systemAdSolution" + const val SHIZUKU = "moe.shizuku.privileged.api" + const val SHIZUKU_RELEASE = "https://github.com/RikkaApps/Shizuku/releases/" - const val coolapk = "com.coolapk.market" - - const val shizuku_coolapk = "coolmarket://apk/moe.shizuku.privileged.api" - const val shizuku_coolapk_url = "https://www.coolapk.com/apk/moe.shizuku.privileged.api" + const val MIUI_ROM = "com.miui.rom" + val FUCKLIST = listOf( + "com.miui.hybrid", + "com.miui.systemAdSolution" + ) } \ No newline at end of file diff --git a/app/src/main/java/com/qhy040404/fxxkmiuiad/MainActivity.kt b/app/src/main/java/com/qhy040404/fxxkmiuiad/MainActivity.kt index 0b2cf8f..18c131c 100644 --- a/app/src/main/java/com/qhy040404/fxxkmiuiad/MainActivity.kt +++ b/app/src/main/java/com/qhy040404/fxxkmiuiad/MainActivity.kt @@ -3,46 +3,42 @@ package com.qhy040404.fxxkmiuiad import android.annotation.SuppressLint import android.content.Intent import android.content.pm.PackageManager -import android.os.Bundle -import android.view.View -import android.widget.Button -import android.widget.TextView import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity import androidx.core.net.toUri -import com.qhy040404.fxxkmiuiad.compat.PMCompat +import androidx.core.view.isVisible +import com.qhy040404.fxxkmiuiad.base.BaseActivity +import com.qhy040404.fxxkmiuiad.databinding.ActivityMainBinding +import com.qhy040404.fxxkmiuiad.utils.OsUtils +import com.qhy040404.fxxkmiuiad.utils.PackageUtils import com.qhy040404.fxxkmiuiad.utils.PackageUtils.getApplicationEnableStateAsString +import com.qhy040404.fxxkmiuiad.utils.ShizukuStatus +import com.qhy040404.fxxkmiuiad.utils.ShizukuUtils import rikka.shizuku.Shizuku import kotlin.concurrent.thread -class MainActivity : AppCompatActivity() { - private var running = true - private var permitted = false - private val callback = Shizuku.OnRequestPermissionResultListener { _, _ -> - this@MainActivity.check(true) +@SuppressLint("SetTextI18n") +class MainActivity : BaseActivity() { + private val callback = Shizuku.OnRequestPermissionResultListener { _, result -> + if (result == PackageManager.PERMISSION_GRANTED) { + this@MainActivity.refreshView() + } else { + runCatching { + PackageUtils.startLaunchAppActivity(this, Constants.SHIZUKU) + Toast.makeText(this, "授权失败,跳转到 Shizuku 手动授权", Toast.LENGTH_LONG).show() + }.onFailure { + Toast.makeText(this, "未检测到 Shizuku, 请手动前往 Sui 授权", Toast.LENGTH_LONG).show() + } + } } - /** - * Fuck list - * - * 《毒瘤列表》 - */ - private val fkList = listOf( - Constants.ad, - Constants.hybrid - ) - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + override fun init() { Shizuku.addRequestPermissionResultListener(callback) - check() initView() } override fun onResume() { super.onResume() - check(true) + refreshView() } override fun onDestroy() { @@ -50,174 +46,161 @@ class MainActivity : AppCompatActivity() { super.onDestroy() } - @SuppressLint("SetTextI18n") - private fun initView() { - val tv = findViewById(R.id.tv) - val enable = findViewById