mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Modify change hideOrShowLauncherIcon in a hard-code way
This commit is contained in:
@@ -30,7 +30,6 @@ object DataConst {
|
|||||||
|
|
||||||
val ENABLE_MODULE = PrefsData("_enable_module", true)
|
val ENABLE_MODULE = PrefsData("_enable_module", true)
|
||||||
val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false)
|
val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false)
|
||||||
val ENABLE_HIDE_ICON = PrefsData("_hide_icon", false)
|
|
||||||
val ENABLE_ANDROID12_STYLE = PrefsData("_notify_android12_style", isUpperOfAndroidS)
|
val ENABLE_ANDROID12_STYLE = PrefsData("_notify_android12_style", isUpperOfAndroidS)
|
||||||
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
||||||
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false)
|
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false)
|
||||||
|
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
package com.fankes.coloros.notify.ui.activity
|
package com.fankes.coloros.notify.ui.activity
|
||||||
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import android.widget.SeekBar.OnSeekBarChangeListener
|
import android.widget.SeekBar.OnSeekBarChangeListener
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -140,7 +138,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.notifyMediaPanelAutoExpSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP)
|
binding.notifyMediaPanelAutoExpSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP)
|
||||||
binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE)
|
binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE)
|
||||||
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
|
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
|
||||||
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_HIDE_ICON)
|
|
||||||
binding.notifyIconFixSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
binding.notifyIconFixSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
binding.notifyIconForceAppIconSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON)
|
binding.notifyIconForceAppIconSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON)
|
||||||
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
||||||
@@ -170,15 +167,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
modulePrefs.put(DataConst.ENABLE_MODULE_LOG, b)
|
modulePrefs.put(DataConst.ENABLE_MODULE_LOG, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
|
||||||
modulePrefs.put(DataConst.ENABLE_HIDE_ICON, b)
|
|
||||||
packageManager.setComponentEnabledSetting(
|
|
||||||
ComponentName(packageName, "com.fankes.coloros.notify.Home"),
|
|
||||||
if (b) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
|
||||||
PackageManager.DONT_KILL_APP
|
|
||||||
)
|
|
||||||
}
|
|
||||||
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX, b)
|
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX, b)
|
||||||
@@ -274,6 +262,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||||
})
|
})
|
||||||
|
/** 设置桌面图标显示隐藏 */
|
||||||
|
binding.hideIconInLauncherSwitch.isChecked = isLauncherIconShowing.not()
|
||||||
|
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
hideOrShowLauncherIcon(b)
|
||||||
|
}
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
/** 自动更新在线规则修改时间按钮点击事件 */
|
/** 自动更新在线规则修改时间按钮点击事件 */
|
||||||
|
@@ -28,12 +28,10 @@ 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.ClipData
|
import android.content.*
|
||||||
import android.content.ClipboardManager
|
|
||||||
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.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
|
||||||
@@ -54,6 +52,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.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
|
||||||
@@ -504,4 +503,27 @@ fun Long.stampToDate(format: String = "yyyy-MM-dd HH:mm:ss") =
|
|||||||
fun Any?.delayedRun(ms: Long = 150, it: () -> Unit) = runInSafe {
|
fun Any?.delayedRun(ms: Long = 150, it: () -> Unit) = runInSafe {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
Handler().postDelayed({ it() }, ms)
|
Handler().postDelayed({ it() }, ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏或显示启动器图标
|
||||||
|
*
|
||||||
|
* - 你可能需要 LSPosed 的最新版本以开启高版本系统中隐藏 APP 桌面图标功能
|
||||||
|
* @param isShow 是否显示
|
||||||
|
*/
|
||||||
|
fun Context.hideOrShowLauncherIcon(isShow: Boolean) {
|
||||||
|
packageManager?.setComponentEnabledSetting(
|
||||||
|
ComponentName(packageName, "${BuildConfig.APPLICATION_ID}.Home"),
|
||||||
|
if (isShow) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取启动器图标状态
|
||||||
|
* @return [Boolean] 是否显示
|
||||||
|
*/
|
||||||
|
val Context.isLauncherIconShowing
|
||||||
|
get() = packageManager?.getComponentEnabledSetting(
|
||||||
|
ComponentName(packageName, "${BuildConfig.APPLICATION_ID}.Home")
|
||||||
|
) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
Reference in New Issue
Block a user