mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
Added custom status bar notification icons alpha function in SystemUIHooker, MainActivity, ConfigData, activity_main
This commit is contained in:
@@ -51,6 +51,12 @@ object ConfigData {
|
|||||||
/** 启用通知图标兼容模式 */
|
/** 启用通知图标兼容模式 */
|
||||||
val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", false)
|
val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", false)
|
||||||
|
|
||||||
|
/** 状态栏中的通知图标暗色透明度 */
|
||||||
|
val STATUS_ICON_DARK_ALPHA_LEVEL = PrefsData("_status_icon_dark_alpha", 75)
|
||||||
|
|
||||||
|
/** 状态栏中的通知图标亮色透明度 */
|
||||||
|
val STATUS_ICON_LIGHT_ALPHA_LEVEL = PrefsData("_status_icon_light_alpha", 95)
|
||||||
|
|
||||||
/** 通知栏中的通知图标圆角程度 */
|
/** 通知栏中的通知图标圆角程度 */
|
||||||
val NOTIFY_ICON_CORNER_SIZE = PrefsData("_notify_icon_corner", 15)
|
val NOTIFY_ICON_CORNER_SIZE = PrefsData("_notify_icon_corner", 15)
|
||||||
|
|
||||||
@@ -218,6 +224,26 @@ object ConfigData {
|
|||||||
putBoolean(ENABLE_COLOR_ICON_COMPAT, value)
|
putBoolean(ENABLE_COLOR_ICON_COMPAT, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态栏中的通知图标暗色透明度
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
var statusIconDarkAlphaLevel
|
||||||
|
get() = getInt(STATUS_ICON_DARK_ALPHA_LEVEL)
|
||||||
|
set(value) {
|
||||||
|
putInt(STATUS_ICON_DARK_ALPHA_LEVEL, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态栏中的通知图标亮色透明度
|
||||||
|
* @return [Int]
|
||||||
|
*/
|
||||||
|
var statusIconLightAlphaLevel
|
||||||
|
get() = getInt(STATUS_ICON_LIGHT_ALPHA_LEVEL)
|
||||||
|
set(value) {
|
||||||
|
putInt(STATUS_ICON_LIGHT_ALPHA_LEVEL, value)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知栏中的通知图标圆角程度
|
* 通知栏中的通知图标圆角程度
|
||||||
* @return [Int]
|
* @return [Int]
|
||||||
|
@@ -165,7 +165,8 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
* 获取状态栏通知图标透明度
|
* 获取状态栏通知图标透明度
|
||||||
* @return [Float]
|
* @return [Float]
|
||||||
*/
|
*/
|
||||||
private val statusBarIconAlpha get() = if (isDarkIconMode) 0.75f else 0.95f
|
private val statusBarIconAlpha
|
||||||
|
get() = (if (isDarkIconMode) ConfigData.statusIconDarkAlphaLevel else ConfigData.statusIconLightAlphaLevel) / 100f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 这个是修复彩色图标的关键核心代码判断
|
* - 这个是修复彩色图标的关键核心代码判断
|
||||||
|
@@ -245,6 +245,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true)
|
SystemUITool.refreshSystemUI(context = this@MainActivity, isRefreshCacheOnly = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.statusDarkIconCustomAlphaSeekbar.bind(
|
||||||
|
ConfigData.STATUS_ICON_DARK_ALPHA_LEVEL, binding.statusDarkIconCustomAlphaText, suffix = "%"
|
||||||
|
) { SystemUITool.refreshSystemUI(context = this) }
|
||||||
|
binding.statusLightIconCustomAlphaSeekbar.bind(
|
||||||
|
ConfigData.STATUS_ICON_LIGHT_ALPHA_LEVEL, binding.statusLightIconCustomAlphaText, suffix = "%"
|
||||||
|
) { SystemUITool.refreshSystemUI(context = this) }
|
||||||
binding.notifyIconCustomCornerSeekbar.bind(ConfigData.NOTIFY_ICON_CORNER_SIZE, binding.notifyIconCustomCornerText, suffix = " dp") {
|
binding.notifyIconCustomCornerSeekbar.bind(ConfigData.NOTIFY_ICON_CORNER_SIZE, binding.notifyIconCustomCornerText, suffix = " dp") {
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
|
@@ -452,14 +452,14 @@
|
|||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="15dp"
|
android:paddingTop="15dp">
|
||||||
android:paddingTop="15dp"
|
|
||||||
android:paddingRight="15dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center|start">
|
android:gravity="center|start"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="15dp"
|
android:layout_width="15dp"
|
||||||
@@ -491,6 +491,8 @@
|
|||||||
android:id="@+id/color_icon_compat_switch"
|
android:id="@+id/color_icon_compat_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
android:text="启用兼容模式"
|
android:text="启用兼容模式"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
@@ -501,9 +503,164 @@
|
|||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:alpha="0.6"
|
android:alpha="0.6"
|
||||||
android:lineSpacingExtra="6dp"
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
android:text="如果发现通知图标颜色判定不正常可启用兼容模式,一般情况下不建议启用兼容模式,发生问题请关闭兼容模式。"
|
android:text="如果发现通知图标颜色判定不正常可启用兼容模式,一般情况下不建议启用兼容模式,发生问题请关闭兼容模式。"
|
||||||
android:textColor="@color/colorTextDark"
|
android:textColor="@color/colorTextDark"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:text="调整状态栏中的通知图标透明度"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatSeekBar
|
||||||
|
android:id="@+id/status_dark_icon_custom_alpha_seekbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:max="100"
|
||||||
|
android:min="10"
|
||||||
|
android:progress="75" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="15dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:alpha="0.75"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:maxWidth="100dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="暗色"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="13.5sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/status_dark_icon_custom_alpha_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:maxWidth="100dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="75%"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatSeekBar
|
||||||
|
android:id="@+id/status_light_icon_custom_alpha_seekbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:max="100"
|
||||||
|
android:min="10"
|
||||||
|
android:progress="95" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="15dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:alpha="0.75"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:maxWidth="100dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="亮色"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="13.5sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/status_light_icon_custom_alpha_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:maxWidth="100dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="95%"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:text="你可以拖拽滑动条来调整状态栏中的通知图标透明度。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:text="仅限单色图标,彩色图标始终以 100% 不透明显示。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Reference in New Issue
Block a user