feat: lots of changes

- add BuildConfigWrapper
- merge to new project promote
- add ci version tag support
- Fix system api compat issues
This commit is contained in:
2023-09-18 00:17:25 +08:00
parent c4573d221b
commit 62d4e727ff
7 changed files with 149 additions and 106 deletions

View File

@@ -20,8 +20,13 @@
* *
* This file is Created by fankes on 2023/2/2. * This file is Created by fankes on 2023/2/2.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate")
package com.fankes.coloros.notify.const package com.fankes.coloros.notify.const
import com.fankes.coloros.notify.generated.AppProperties
import com.fankes.coloros.notify.wrapper.BuildConfigWrapper
/** /**
* 包名常量定义类 * 包名常量定义类
*/ */
@@ -50,4 +55,27 @@ object IconRuleSourceSyncType {
/** 自定义地址 */ /** 自定义地址 */
const val CUSTOM_URL = 3000 const val CUSTOM_URL = 3000
}
/**
* 模块版本常量定义类
*/
object ModuleVersion {
/** 当前 GitHub 提交的 ID (CI 自动构建) */
const val GITHUB_COMMIT_ID = AppProperties.GITHUB_CI_COMMIT_ID
/** 版本名称 */
const val NAME = BuildConfigWrapper.VERSION_NAME
/** 版本号 */
const val CODE = BuildConfigWrapper.VERSION_CODE
/** 是否为 CI 自动构建版本 */
val isCiMode = GITHUB_COMMIT_ID.isNotBlank()
/** 当前版本名称后缀 */
val suffix = GITHUB_COMMIT_ID.let { if (it.isNotBlank()) "-$it" else "" }
override fun toString() = "$NAME$suffix($CODE)"
} }

View File

@@ -25,18 +25,29 @@
package com.fankes.coloros.notify.ui.activity package com.fankes.coloros.notify.ui.activity
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.fankes.coloros.notify.BuildConfig
import com.fankes.coloros.notify.R import com.fankes.coloros.notify.R
import com.fankes.coloros.notify.const.ModuleVersion
import com.fankes.coloros.notify.data.ConfigData import com.fankes.coloros.notify.data.ConfigData
import com.fankes.coloros.notify.data.factory.bind import com.fankes.coloros.notify.data.factory.bind
import com.fankes.coloros.notify.databinding.ActivityMainBinding import com.fankes.coloros.notify.databinding.ActivityMainBinding
import com.fankes.coloros.notify.param.IconPackParams import com.fankes.coloros.notify.param.IconPackParams
import com.fankes.coloros.notify.ui.activity.base.BaseActivity import com.fankes.coloros.notify.ui.activity.base.BaseActivity
import com.fankes.coloros.notify.utils.factory.* import com.fankes.coloros.notify.utils.factory.androidVersionCodeName
import com.fankes.coloros.notify.utils.factory.colorOSFullVersion
import com.fankes.coloros.notify.utils.factory.colorOSNumberVersion
import com.fankes.coloros.notify.utils.factory.hideOrShowLauncherIcon
import com.fankes.coloros.notify.utils.factory.isLauncherIconShowing
import com.fankes.coloros.notify.utils.factory.isNotColorOS
import com.fankes.coloros.notify.utils.factory.isNotNoificationEnabled
import com.fankes.coloros.notify.utils.factory.navigate
import com.fankes.coloros.notify.utils.factory.openBrowser
import com.fankes.coloros.notify.utils.factory.openNotifySetting
import com.fankes.coloros.notify.utils.factory.showDialog
import com.fankes.coloros.notify.utils.factory.showTimePicker
import com.fankes.coloros.notify.utils.tool.GithubReleaseTool import com.fankes.coloros.notify.utils.tool.GithubReleaseTool
import com.fankes.coloros.notify.utils.tool.I18nWarnTool import com.fankes.coloros.notify.utils.tool.I18nWarnTool
import com.fankes.coloros.notify.utils.tool.SystemUITool import com.fankes.coloros.notify.utils.tool.SystemUITool
import com.fankes.coloros.notify.utils.tool.YukiPromoteTool import com.fankes.projectpromote.ProjectPromote
import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.YukiHookAPI
class MainActivity : BaseActivity<ActivityMainBinding>() { class MainActivity : BaseActivity<ActivityMainBinding>() {
@@ -51,19 +62,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
/** 模块是否有效 */ /** 模块是否有效 */
internal var isModuleValied = false internal var isModuleValied = false
/** 模块版本 */
private const val moduleVersion = BuildConfig.VERSION_NAME
/** 预发布的版本标识 */
private const val pendingFlag = ""
} }
override fun onCreate() { override fun onCreate() {
/** 设置可用性 */ /** 设置可用性 */
isActivityLive = true isActivityLive = true
/** 检查更新 */ /** 检查更新 */
GithubReleaseTool.checkingForUpdate(context = this, moduleVersion) { version, function -> GithubReleaseTool.checkingForUpdate(context = this, ModuleVersion.NAME) { version, function ->
binding.mainTextReleaseVersion.apply { binding.mainTextReleaseVersion.apply {
text = "点击更新 $version" text = "点击更新 $version"
isVisible = true isVisible = true
@@ -89,7 +94,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
showDialog { showDialog {
title = "配置通知图标优化名单" title = "配置通知图标优化名单"
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" + msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
"你可以随时在本页面下方找到“配置通知图标优化名单”手动前往。" "你可以随时在本页面下方找到“配置通知图标优化名单”手动前往。"
confirmButton(text = "前往") { navigate<ConfigureActivity>() } confirmButton(text = "前往") { navigate<ConfigureActivity>() }
cancelButton() cancelButton()
noCancelable() noCancelable()
@@ -103,21 +108,39 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
noCancelable() noCancelable()
} }
/** 推广、恰饭 */ /** 推广、恰饭 */
YukiPromoteTool.promote(context = this) ProjectPromote.show(activity = this, ModuleVersion.toString())
} }
else -> else ->
showDialog { showDialog {
title = "模块没有激活" title = "模块没有激活"
msg = "检测到模块没有激活,模块需要 Xposed 环境依赖," + msg = "检测到模块没有激活,模块需要 Xposed 环境依赖," +
"同时需要系统拥有 Root 权限," + "同时需要系统拥有 Root 权限," +
"请自行查看本页面使用帮助与说明第二条。\n" + "请自行查看本页面使用帮助与说明第二条。\n" +
"由于需要修改系统应用达到效果,模块不支持太极阴、应用转生。" "由于需要修改系统应用达到效果,模块不支持太极阴、应用转生。"
confirmButton(text = "我知道了") confirmButton(text = "我知道了")
noCancelable() noCancelable()
} }
} }
I18nWarnTool.checkingOrShowing(context = this) I18nWarnTool.checkingOrShowing(context = this)
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag" binding.mainTextVersion.text = "模块版本:${ModuleVersion.NAME}"
/** 设置 CI 自动构建标识 */
if (ModuleVersion.isCiMode)
binding.mainTextReleaseVersion.apply {
text = "CI ${ModuleVersion.GITHUB_COMMIT_ID}"
isVisible = true
setOnClickListener {
showDialog {
title = "CI 自动构建说明"
msg = """
你正在使用的是 CI 自动构建版本Commit ID 为 ${ModuleVersion.GITHUB_COMMIT_ID}
它是由代码提交后自动触发并构建、自动编译发布的,并未经任何稳定性测试,使用风险自负。
""".trimIndent()
confirmButton(text = "我知道了")
noCancelable()
}
}
}
binding.mainTextColorOsVersion.text = "系统版本:[$androidVersionCodeName] $colorOSFullVersion" binding.mainTextColorOsVersion.text = "系统版本:[$androidVersionCodeName] $colorOSFullVersion"
/** 媒体通知自动展开仅支持 12.1 - 旧版本适配过于复杂已放弃 */ /** 媒体通知自动展开仅支持 12.1 - 旧版本适配过于复杂已放弃 */
if (colorOSNumberVersion != "V12.1") { if (colorOSNumberVersion != "V12.1") {
@@ -168,8 +191,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
if (it) showDialog { if (it) showDialog {
title = "启用兼容模式" title = "启用兼容模式"
msg = "启用兼容模式可修复部分系统版本可能出现无法判定通知图标反色的问题," + msg = "启用兼容模式可修复部分系统版本可能出现无法判定通知图标反色的问题," +
"但是这也可能会导致新的问题,一般情况下不建议开启,确定要继续吗?\n\n" + "但是这也可能会导致新的问题,一般情况下不建议开启,确定要继续吗?\n\n" +
"如果系统界面刷新后通知图标颜色发生错误,请尝试重启一次系统界面。" "如果系统界面刷新后通知图标颜色发生错误,请尝试重启一次系统界面。"
confirmButton { applyChangesAndRefresh() } confirmButton { applyChangesAndRefresh() }
cancelButton { cancelChanges() } cancelButton { cancelChanges() }
noCancelable() noCancelable()
@@ -194,7 +217,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
if (it) showDialog { if (it) showDialog {
title = "破坏性功能警告" title = "破坏性功能警告"
msg = "开启这个功能后,任何通知栏中的通知图标都会忽略图标自身的着色属性,全部使用系统默认颜色 (系统提供的统一色调) 着色。\n\n" + msg = "开启这个功能后,任何通知栏中的通知图标都会忽略图标自身的着色属性,全部使用系统默认颜色 (系统提供的统一色调) 着色。\n\n" +
"此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?" "此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?"
confirmButton { applyChangesAndRefresh() } confirmButton { applyChangesAndRefresh() }
cancelButton { cancelChanges() } cancelButton { cancelChanges() }
noCancelable() noCancelable()
@@ -216,8 +239,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
if (it) showDialog { if (it) showDialog {
title = "破坏性功能警告" title = "破坏性功能警告"
msg = "开启这个功能后,任何通知栏中的通知图标都会被强制替换为当前推送通知的 APP 的图标," + msg = "开启这个功能后,任何通知栏中的通知图标都会被强制替换为当前推送通知的 APP 的图标," +
"某些系统级别的 APP 通知图标可能会显示异常或发生图标丢失。\n\n" + "某些系统级别的 APP 通知图标可能会显示异常或发生图标丢失。\n\n" +
"此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?" "此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?"
confirmButton { applyChangesAndRefresh() } confirmButton { applyChangesAndRefresh() }
cancelButton { cancelChanges() } cancelButton { cancelChanges() }
noCancelable() noCancelable()
@@ -261,9 +284,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
if (it) showDialog { if (it) showDialog {
title = "注意" title = "注意"
msg = "开启这个功能后,当发现未适配的彩色通知图标时," + msg = "开启这个功能后,当发现未适配的彩色通知图标时," +
"状态栏中显示的通知图标将会使用预置的占位符图标进行修补," + "状态栏中显示的通知图标将会使用预置的占位符图标进行修补," +
"通知栏中显示的通知图标保持原始图标不变。\n\n" + "通知栏中显示的通知图标保持原始图标不变。\n\n" +
"此功能的作用仅为临时修复破坏规范的通知图标,仍然继续开启吗?" "此功能的作用仅为临时修复破坏规范的通知图标,仍然继续开启吗?"
confirmButton { applyChangesAndRefresh() } confirmButton { applyChangesAndRefresh() }
cancelButton { cancelChanges() } cancelButton { cancelChanges() }
noCancelable() noCancelable()
@@ -296,11 +319,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
showDialog { showDialog {
title = "每天 $it 自动更新" title = "每天 $it 自动更新"
msg = "设置保存后将在每天 $it 自动同步名单到最新云端数据,若数据已是最新则不会显示任何提示,否则会发送一条通知。\n\n" + msg = "设置保存后将在每天 $it 自动同步名单到最新云端数据,若数据已是最新则不会显示任何提示,否则会发送一条通知。\n\n" +
"请确保:\n\n" + "请确保:\n\n" +
"1.模块没有被禁止前台以及后台联网权限\n" + "1.模块没有被禁止前台以及后台联网权限\n" +
"2.模块没有被禁止被其它 APP 关联唤醒\n" + "2.模块没有被禁止被其它 APP 关联唤醒\n" +
"3.模块的系统通知权限已开启\n\n" + "3.模块的系统通知权限已开启\n\n" +
"模块无需保持在后台运行,到达同步时间后会自动启动,如果到达时间后模块正在运行则会自动取消本次计划任务。" "模块无需保持在后台运行,到达同步时间后会自动启动,如果到达时间后模块正在运行则会自动取消本次计划任务。"
confirmButton(text = "保存设置") { confirmButton(text = "保存设置") {
ConfigData.notifyIconFixAutoTime = it ConfigData.notifyIconFixAutoTime = it
this@MainActivity.binding.notifyIconAutoSyncText.text = it this@MainActivity.binding.notifyIconAutoSyncText.text = it
@@ -334,7 +357,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
binding.mainLinStatus.setBackgroundResource( binding.mainLinStatus.setBackgroundResource(
when { when {
YukiHookAPI.Status.isXposedModuleActive && YukiHookAPI.Status.isXposedModuleActive &&
(isModuleRegular.not() || isModuleValied.not() || ConfigData.isEnableModule.not()) -> R.drawable.bg_yellow_round (isModuleRegular.not() || isModuleValied.not() || ConfigData.isEnableModule.not()) -> R.drawable.bg_yellow_round
YukiHookAPI.Status.isXposedModuleActive -> R.drawable.bg_green_round YukiHookAPI.Status.isXposedModuleActive -> R.drawable.bg_green_round
else -> R.drawable.bg_dark_round else -> R.drawable.bg_dark_round
} }

View File

@@ -28,7 +28,11 @@ import android.app.Activity
import android.app.Notification import android.app.Notification
import android.app.Service import android.app.Service
import android.app.WallpaperManager import android.app.WallpaperManager
import android.content.* import android.content.ClipData
import android.content.ClipboardManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
@@ -52,7 +56,7 @@ import androidx.core.app.NotificationManagerCompat
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.core.content.pm.PackageInfoCompat import androidx.core.content.pm.PackageInfoCompat
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import com.fankes.coloros.notify.BuildConfig import com.fankes.coloros.notify.wrapper.BuildConfigWrapper
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.hasClass import com.highcapable.yukihookapi.hook.factory.hasClass
@@ -63,7 +67,9 @@ import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication.Com
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.Calendar
import java.util.Date
import java.util.Locale
/** /**
* 系统深色模式是否开启 * 系统深色模式是否开启
@@ -203,7 +209,7 @@ fun Resources.colorOf(@ColorRes resId: Int) = ResourcesCompat.getColor(this, res
* @return [PackageInfo] or null * @return [PackageInfo] or null
*/ */
private fun Context.getPackageInfoCompat(packageName: String, flag: Number = 0) = runCatching { private fun Context.getPackageInfoCompat(packageName: String, flag: Number = 0) = runCatching {
@Suppress("DEPRECATION") @Suppress("DEPRECATION", "KotlinRedundantDiagnosticSuppress")
if (Build.VERSION.SDK_INT >= 33) if (Build.VERSION.SDK_INT >= 33)
packageManager?.getPackageInfo(packageName, PackageInfoFlags.of(flag.toLong())) packageManager?.getPackageInfo(packageName, PackageInfoFlags.of(flag.toLong()))
else packageManager?.getPackageInfo(packageName, flag.toInt()) else packageManager?.getPackageInfo(packageName, flag.toInt())
@@ -416,7 +422,10 @@ fun findPropString(key: String, default: String = "") = safeOf(default) {
* 是否有 Root 权限 * 是否有 Root 权限
* @return [Boolean] * @return [Boolean]
*/ */
val isRootAccess get() = safeOfFalse { Shell.rootAccess() } val isRootAccess get() = safeOfFalse {
@Suppress("DEPRECATION")
Shell.rootAccess()
}
/** /**
* 执行命令 * 执行命令
@@ -425,6 +434,7 @@ val isRootAccess get() = safeOfFalse { Shell.rootAccess() }
* @return [String] 执行结果 * @return [String] 执行结果
*/ */
fun execShell(cmd: String, isSu: Boolean = true) = safeOfNothing { fun execShell(cmd: String, isSu: Boolean = true) = safeOfNothing {
@Suppress("DEPRECATION")
(if (isSu) Shell.su(cmd) else Shell.sh(cmd)).exec().out.let { (if (isSu) Shell.su(cmd) else Shell.sh(cmd)).exec().out.let {
if (it.isNotEmpty()) it[0].trim() else "" if (it.isNotEmpty()) it[0].trim() else ""
} }
@@ -541,7 +551,7 @@ fun Any?.delayedRun(ms: Long = 150, it: () -> Unit) = runInSafe {
*/ */
fun Context.hideOrShowLauncherIcon(isShow: Boolean) { fun Context.hideOrShowLauncherIcon(isShow: Boolean) {
packageManager?.setComponentEnabledSetting( packageManager?.setComponentEnabledSetting(
ComponentName(packageName, "${BuildConfig.APPLICATION_ID}.Home"), ComponentName(packageName, "${BuildConfigWrapper.APPLICATION_ID}.Home"),
if (isShow) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED, if (isShow) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP PackageManager.DONT_KILL_APP
) )
@@ -553,5 +563,5 @@ fun Context.hideOrShowLauncherIcon(isShow: Boolean) {
*/ */
val Context.isLauncherIconShowing val Context.isLauncherIconShowing
get() = packageManager?.getComponentEnabledSetting( get() = packageManager?.getComponentEnabledSetting(
ComponentName(packageName, "${BuildConfig.APPLICATION_ID}.Home") ComponentName(packageName, "${BuildConfigWrapper.APPLICATION_ID}.Home")
) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED ) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED

View File

@@ -32,9 +32,9 @@ import android.content.Intent
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.os.Build import android.os.Build
import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toBitmap
import com.fankes.coloros.notify.BuildConfig
import com.fankes.coloros.notify.R import com.fankes.coloros.notify.R
import com.fankes.coloros.notify.utils.factory.appIconOf import com.fankes.coloros.notify.utils.factory.appIconOf
import com.fankes.coloros.notify.wrapper.BuildConfigWrapper
/** /**
* 模块更新激活提醒通知工具类 * 模块更新激活提醒通知工具类
@@ -42,7 +42,7 @@ import com.fankes.coloros.notify.utils.factory.appIconOf
object ActivationPromptTool { object ActivationPromptTool {
/** 当前模块的包名 */ /** 当前模块的包名 */
private const val MODULE_PACKAGE_NAME = BuildConfig.APPLICATION_ID private const val MODULE_PACKAGE_NAME = BuildConfigWrapper.APPLICATION_ID
/** 推送通知的渠道名称 */ /** 推送通知的渠道名称 */
private const val NOTIFY_CHANNEL = "activationPromptId" private const val NOTIFY_CHANNEL = "activationPromptId"
@@ -53,7 +53,7 @@ object ActivationPromptTool {
* @param packageName 当前 APP 包名 * @param packageName 当前 APP 包名
*/ */
fun prompt(context: Context, packageName: String) { fun prompt(context: Context, packageName: String) {
if (packageName != BuildConfig.APPLICATION_ID) return if (packageName != BuildConfigWrapper.APPLICATION_ID) return
context.getSystemService(NotificationManager::class.java)?.apply { context.getSystemService(NotificationManager::class.java)?.apply {
createNotificationChannel( createNotificationChannel(
NotificationChannel( NotificationChannel(
@@ -73,7 +73,7 @@ object ActivationPromptTool {
PendingIntent.getActivity( PendingIntent.getActivity(
context, packageName.hashCode(), context, packageName.hashCode(),
Intent().apply { Intent().apply {
component = ComponentName(MODULE_PACKAGE_NAME, "${MODULE_PACKAGE_NAME}.ui.activity.MainActivity") component = ComponentName(MODULE_PACKAGE_NAME, "$MODULE_PACKAGE_NAME.ui.activity.MainActivity")
flags = Intent.FLAG_ACTIVITY_NEW_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK
}, if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE }, if (Build.VERSION.SDK_INT < 31) PendingIntent.FLAG_UPDATE_CURRENT else PendingIntent.FLAG_IMMUTABLE
) )

View File

@@ -32,10 +32,15 @@ import android.content.Intent
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.os.Build import android.os.Build
import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toBitmap
import com.fankes.coloros.notify.BuildConfig
import com.fankes.coloros.notify.R import com.fankes.coloros.notify.R
import com.fankes.coloros.notify.hook.HookEntry import com.fankes.coloros.notify.hook.HookEntry
import com.fankes.coloros.notify.utils.factory.* import com.fankes.coloros.notify.utils.factory.appIconOf
import com.fankes.coloros.notify.utils.factory.appNameOf
import com.fankes.coloros.notify.utils.factory.isDebugApp
import com.fankes.coloros.notify.utils.factory.isSystemApp
import com.fankes.coloros.notify.utils.factory.runInSafe
import com.fankes.coloros.notify.utils.factory.stampToDate
import com.fankes.coloros.notify.wrapper.BuildConfigWrapper
/** /**
* 通知图标适配推送通知类 * 通知图标适配推送通知类
@@ -45,7 +50,7 @@ import com.fankes.coloros.notify.utils.factory.*
object IconAdaptationTool { object IconAdaptationTool {
/** 当前模块的包名 */ /** 当前模块的包名 */
private const val MODULE_PACKAGE_NAME = BuildConfig.APPLICATION_ID private const val MODULE_PACKAGE_NAME = BuildConfigWrapper.APPLICATION_ID
/** 推送通知的渠道名称 */ /** 推送通知的渠道名称 */
private const val NOTIFY_CHANNEL = "notifyRuleSupportId" private const val NOTIFY_CHANNEL = "notifyRuleSupportId"
@@ -82,7 +87,7 @@ object IconAdaptationTool {
Intent().apply { Intent().apply {
component = ComponentName( component = ComponentName(
MODULE_PACKAGE_NAME, MODULE_PACKAGE_NAME,
"${MODULE_PACKAGE_NAME}.ui.activity.ConfigureActivity" "$MODULE_PACKAGE_NAME.ui.activity.ConfigureActivity"
) )
flags = Intent.FLAG_ACTIVITY_NEW_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK
}.apply { }.apply {
@@ -117,7 +122,7 @@ object IconAdaptationTool {
outTimeLimits.add(nowTime) outTimeLimits.add(nowTime)
context.startActivity( context.startActivity(
Intent().apply { Intent().apply {
component = ComponentName(MODULE_PACKAGE_NAME, "${MODULE_PACKAGE_NAME}.ui.activity.auto.NotifyIconRuleUpdateActivity") component = ComponentName(MODULE_PACKAGE_NAME, "$MODULE_PACKAGE_NAME.ui.activity.auto.NotifyIconRuleUpdateActivity")
flags = Intent.FLAG_ACTIVITY_NEW_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK
} }
) )

View File

@@ -1,60 +0,0 @@
/*
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
* Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com)
* https://github.com/fankes/ColorOSNotifyIcon
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
* <p>
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* and eula along with this software. If not, see
* <https://www.gnu.org/licenses/>
*
* This file is Created by fankes on 2022/5/30.
*/
package com.fankes.coloros.notify.utils.tool
import android.content.Context
import com.fankes.coloros.notify.BuildConfig
import com.fankes.coloros.notify.utils.factory.openBrowser
import com.fankes.coloros.notify.utils.factory.showDialog
import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.hook.factory.prefs
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
/**
* [YukiHookAPI] 的自动推广工具类
*/
object YukiPromoteTool {
/** 推广已读存储键值 */
private val YUKI_PROMOTE_READED = PrefsData("yuki_promote_readed_${BuildConfig.VERSION_NAME}", false)
/**
* 显示推广对话框
* @param context 实例
*/
fun promote(context: Context) {
fun saveReaded() = context.prefs().edit { put(YUKI_PROMOTE_READED, value = true) }
if (context.prefs().get(YUKI_PROMOTE_READED).not())
context.showDialog {
title = "面向开发者的推广"
msg = "你想快速拥有一个自己的 Xposed 模块吗,你只需要拥有基础的 Android 开发经验以及使用 Kotlin 编程语言即可。\n\n" +
"快来体验 YukiHookAPI这是一个使用 Kotlin 构建的高效 Hook API 与 Xposed 模块解决方案,助你的开发变得更轻松。"
confirmButton(text = "去看看") {
context.openBrowser(url = "https://github.com/fankes/YukiHookAPI")
saveReaded()
}
cancelButton(text = "我不是开发者") { saveReaded() }
noCancelable()
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* ColorOSNotifyIcon - Optimize notification icons for ColorOS and adapt to native notification icon specifications.
* Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com)
* https://github.com/fankes/ColorOSNotifyIcon
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
* <p>
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* and eula along with this software. If not, see
* <https://www.gnu.org/licenses/>
*
* This file is created by fankes on 2023/9/17.
*/
@file:Suppress("unused")
package com.fankes.coloros.notify.wrapper
import com.fankes.coloros.notify.BuildConfig
/**
* 对 [BuildConfig] 的包装
*/
object BuildConfigWrapper {
const val APPLICATION_ID = BuildConfig.APPLICATION_ID
const val VERSION_NAME = BuildConfig.VERSION_NAME
const val VERSION_CODE = BuildConfig.VERSION_CODE
val isDebug = BuildConfig.DEBUG
}