mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
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:
@@ -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.miui.notify.const
|
package com.fankes.miui.notify.const
|
||||||
|
|
||||||
|
import com.fankes.miui.notify.generated.AppProperties
|
||||||
|
import com.fankes.miui.notify.wrapper.BuildConfigWrapper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包名常量定义类
|
* 包名常量定义类
|
||||||
*/
|
*/
|
||||||
@@ -48,3 +53,26 @@ 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)"
|
||||||
|
}
|
@@ -26,19 +26,35 @@ package com.fankes.miui.notify.ui.activity
|
|||||||
|
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.fankes.miui.notify.BuildConfig
|
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
|
import com.fankes.miui.notify.const.ModuleVersion
|
||||||
import com.fankes.miui.notify.data.ConfigData
|
import com.fankes.miui.notify.data.ConfigData
|
||||||
import com.fankes.miui.notify.data.factory.bind
|
import com.fankes.miui.notify.data.factory.bind
|
||||||
import com.fankes.miui.notify.databinding.ActivityMainBinding
|
import com.fankes.miui.notify.databinding.ActivityMainBinding
|
||||||
import com.fankes.miui.notify.databinding.DiaStatusIconCountBinding
|
import com.fankes.miui.notify.databinding.DiaStatusIconCountBinding
|
||||||
import com.fankes.miui.notify.params.IconPackParams
|
import com.fankes.miui.notify.params.IconPackParams
|
||||||
import com.fankes.miui.notify.ui.activity.base.BaseActivity
|
import com.fankes.miui.notify.ui.activity.base.BaseActivity
|
||||||
import com.fankes.miui.notify.utils.factory.*
|
import com.fankes.miui.notify.utils.factory.androidVersionCodeName
|
||||||
|
import com.fankes.miui.notify.utils.factory.hideOrShowLauncherIcon
|
||||||
|
import com.fankes.miui.notify.utils.factory.isLauncherIconShowing
|
||||||
|
import com.fankes.miui.notify.utils.factory.isLowerAndroidP
|
||||||
|
import com.fankes.miui.notify.utils.factory.isLowerAndroidR
|
||||||
|
import com.fankes.miui.notify.utils.factory.isNotMIUI
|
||||||
|
import com.fankes.miui.notify.utils.factory.isNotNoificationEnabled
|
||||||
|
import com.fankes.miui.notify.utils.factory.isNotSupportMiuiVersion
|
||||||
|
import com.fankes.miui.notify.utils.factory.miuiFullVersion
|
||||||
|
import com.fankes.miui.notify.utils.factory.miuiVersion
|
||||||
|
import com.fankes.miui.notify.utils.factory.miuiVersionCode
|
||||||
|
import com.fankes.miui.notify.utils.factory.navigate
|
||||||
|
import com.fankes.miui.notify.utils.factory.openBrowser
|
||||||
|
import com.fankes.miui.notify.utils.factory.openNotifySetting
|
||||||
|
import com.fankes.miui.notify.utils.factory.showDialog
|
||||||
|
import com.fankes.miui.notify.utils.factory.showTimePicker
|
||||||
|
import com.fankes.miui.notify.utils.factory.snake
|
||||||
import com.fankes.miui.notify.utils.tool.GithubReleaseTool
|
import com.fankes.miui.notify.utils.tool.GithubReleaseTool
|
||||||
import com.fankes.miui.notify.utils.tool.I18nWarnTool
|
import com.fankes.miui.notify.utils.tool.I18nWarnTool
|
||||||
import com.fankes.miui.notify.utils.tool.SystemUITool
|
import com.fankes.miui.notify.utils.tool.SystemUITool
|
||||||
import com.fankes.miui.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>() {
|
||||||
@@ -53,19 +69,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
|
||||||
@@ -103,7 +113,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
showDialog {
|
showDialog {
|
||||||
title = "不支持的 MIUI 版本"
|
title = "不支持的 MIUI 版本"
|
||||||
msg = (if (miuiVersion.isNotBlank())
|
msg = (if (miuiVersion.isNotBlank())
|
||||||
"此模块目前支持 MIUI 11~14 系统,你的 MIUI 版本为 ${miuiVersion},暂不支持。\n\n" +
|
"此模块目前支持 MIUI 11~14 系统,你的 MIUI 版本为 $miuiVersion,暂不支持。\n\n" +
|
||||||
"如果你的 MIUI 版本识别有误,请检查是否有相关插件修改了系统版本。\n\n"
|
"如果你的 MIUI 版本识别有误,请检查是否有相关插件修改了系统版本。\n\n"
|
||||||
else "无法获取 MIUI 版本,请检查你是否修改了系统参数或使用非官方系统。\n\n") + "若有其它疑问,你可以点击下方按钮前往项目地址进行反馈。"
|
else "无法获取 MIUI 版本,请检查你是否修改了系统参数或使用非官方系统。\n\n") + "若有其它疑问,你可以点击下方按钮前往项目地址进行反馈。"
|
||||||
confirmButton(text = "前往项目地址") {
|
confirmButton(text = "前往项目地址") {
|
||||||
@@ -141,7 +151,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
/** 推广、恰饭 */
|
/** 推广、恰饭 */
|
||||||
YukiPromoteTool.promote(context = this)
|
ProjectPromote.show(activity = this, ModuleVersion.toString())
|
||||||
}
|
}
|
||||||
else ->
|
else ->
|
||||||
showDialog {
|
showDialog {
|
||||||
@@ -155,7 +165,25 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion"
|
binding.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion"
|
||||||
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
|
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
|
||||||
binding.warnMiuiNotifyStyleTip.isGone = miuiVersionCode > 11
|
binding.warnMiuiNotifyStyleTip.isGone = miuiVersionCode > 11
|
||||||
|
@@ -28,14 +28,26 @@ 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
|
||||||
import android.content.pm.PackageManager.PackageInfoFlags
|
import android.content.pm.PackageManager.PackageInfoFlags
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.*
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffXfermode
|
||||||
|
import android.graphics.Rect
|
||||||
|
import android.graphics.RectF
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@@ -50,7 +62,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.miui.notify.BuildConfig
|
import com.fankes.miui.notify.wrapper.BuildConfigWrapper
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.highcapable.yukihookapi.hook.factory.hasClass
|
import com.highcapable.yukihookapi.hook.factory.hasClass
|
||||||
import com.highcapable.yukihookapi.hook.factory.method
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
@@ -60,7 +72,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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统深色模式是否开启
|
* 系统深色模式是否开启
|
||||||
@@ -225,7 +239,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())
|
||||||
@@ -460,7 +474,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()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行命令
|
* 执行命令
|
||||||
@@ -469,6 +486,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 ""
|
||||||
}
|
}
|
||||||
@@ -587,7 +605,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
|
||||||
)
|
)
|
||||||
@@ -599,5 +617,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
|
@@ -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.miui.notify.BuildConfig
|
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
import com.fankes.miui.notify.utils.factory.appIconOf
|
import com.fankes.miui.notify.utils.factory.appIconOf
|
||||||
|
import com.fankes.miui.notify.wrapper.BuildConfigWrapper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模块更新激活提醒通知工具类
|
* 模块更新激活提醒通知工具类
|
||||||
@@ -42,7 +42,7 @@ import com.fankes.miui.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
|
||||||
)
|
)
|
||||||
|
@@ -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.miui.notify.BuildConfig
|
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
import com.fankes.miui.notify.hook.HookEntry
|
import com.fankes.miui.notify.hook.HookEntry
|
||||||
import com.fankes.miui.notify.utils.factory.*
|
import com.fankes.miui.notify.utils.factory.appIconOf
|
||||||
|
import com.fankes.miui.notify.utils.factory.appNameOf
|
||||||
|
import com.fankes.miui.notify.utils.factory.isDebugApp
|
||||||
|
import com.fankes.miui.notify.utils.factory.isSystemApp
|
||||||
|
import com.fankes.miui.notify.utils.factory.runInSafe
|
||||||
|
import com.fankes.miui.notify.utils.factory.stampToDate
|
||||||
|
import com.fankes.miui.notify.wrapper.BuildConfigWrapper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知图标适配推送通知类
|
* 通知图标适配推送通知类
|
||||||
@@ -45,7 +50,7 @@ import com.fankes.miui.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
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team.
|
|
||||||
* Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com)
|
|
||||||
* https://github.com/fankes/MIUINativeNotifyIcon
|
|
||||||
*
|
|
||||||
* 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.miui.notify.utils.tool
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.fankes.miui.notify.BuildConfig
|
|
||||||
import com.fankes.miui.notify.utils.factory.openBrowser
|
|
||||||
import com.fankes.miui.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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team.
|
||||||
|
* Copyright (C) 2017-2023 Fankes Studio(qzmmcn@163.com)
|
||||||
|
* https://github.com/fankes/MIUINativeNotifyIcon
|
||||||
|
*
|
||||||
|
* 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.miui.notify.wrapper
|
||||||
|
|
||||||
|
import com.fankes.miui.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
|
||||||
|
}
|
Reference in New Issue
Block a user