mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
布局更换为 ViewBinding 并适配 MD3 风格对话框
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -7,6 +7,7 @@
|
|||||||
<entry key="app/src/main/res/drawable-night/permotion_round.xml" value="0.256" />
|
<entry key="app/src/main/res/drawable-night/permotion_round.xml" value="0.256" />
|
||||||
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.44871794871794873" />
|
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.44871794871794873" />
|
||||||
<entry key="app/src/main/res/drawable/bg_dark_round.xml" value="0.2325" />
|
<entry key="app/src/main/res/drawable/bg_dark_round.xml" value="0.2325" />
|
||||||
|
<entry key="app/src/main/res/drawable/bg_dialog_background.xml" value="0.2325" />
|
||||||
<entry key="app/src/main/res/drawable/bg_green_round.xml" value="0.255" />
|
<entry key="app/src/main/res/drawable/bg_green_round.xml" value="0.255" />
|
||||||
<entry key="app/src/main/res/drawable/bg_warn_round.xml" value="0.2325" />
|
<entry key="app/src/main/res/drawable/bg_warn_round.xml" value="0.2325" />
|
||||||
<entry key="app/src/main/res/drawable/bg_yellow_round.xml" value="0.255" />
|
<entry key="app/src/main/res/drawable/bg_yellow_round.xml" value="0.255" />
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# MIUI 原生通知图标
|
# MIUI 原生通知图标
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
[](https://t.me/XiaofangInternet)
|
[](https://t.me/XiaofangInternet)
|
||||||
|
@@ -30,7 +30,7 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
android:value="93" />
|
android:value="93" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.activity.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:screenOrientation="behind">
|
android:screenOrientation="behind">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:targetActivity=".ui.MainActivity">
|
android:targetActivity=".ui.activity.MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConfigureActivity"
|
android:name=".ui.activity.ConfigureActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="behind" />
|
android:screenOrientation="behind" />
|
||||||
</application>
|
</application>
|
||||||
|
@@ -22,21 +22,17 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("SetTextI18n", "InflateParams", "DEPRECATION")
|
@file:Suppress("SetTextI18n", "InflateParams", "DEPRECATION")
|
||||||
|
|
||||||
package com.fankes.miui.notify.ui
|
package com.fankes.miui.notify.ui.activity
|
||||||
|
|
||||||
import android.app.ProgressDialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.BaseAdapter
|
import android.widget.BaseAdapter
|
||||||
import android.widget.ListView
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
import com.fankes.miui.notify.bean.IconDataBean
|
import com.fankes.miui.notify.bean.IconDataBean
|
||||||
|
import com.fankes.miui.notify.databinding.*
|
||||||
import com.fankes.miui.notify.hook.HookConst.SOURCE_SYNC_WAY
|
import com.fankes.miui.notify.hook.HookConst.SOURCE_SYNC_WAY
|
||||||
import com.fankes.miui.notify.hook.HookConst.SOURCE_SYNC_WAY_CUSTOM_URL
|
import com.fankes.miui.notify.hook.HookConst.SOURCE_SYNC_WAY_CUSTOM_URL
|
||||||
import com.fankes.miui.notify.hook.HookConst.TYPE_SOURCE_SYNC_WAY_1
|
import com.fankes.miui.notify.hook.HookConst.TYPE_SOURCE_SYNC_WAY_1
|
||||||
@@ -47,17 +43,14 @@ import com.fankes.miui.notify.hook.factory.isAppNotifyHookOf
|
|||||||
import com.fankes.miui.notify.hook.factory.putAppNotifyHookAllOf
|
import com.fankes.miui.notify.hook.factory.putAppNotifyHookAllOf
|
||||||
import com.fankes.miui.notify.hook.factory.putAppNotifyHookOf
|
import com.fankes.miui.notify.hook.factory.putAppNotifyHookOf
|
||||||
import com.fankes.miui.notify.params.IconPackParams
|
import com.fankes.miui.notify.params.IconPackParams
|
||||||
import com.fankes.miui.notify.ui.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.*
|
||||||
import com.fankes.miui.notify.utils.tool.ClientRequestTool
|
import com.fankes.miui.notify.utils.tool.ClientRequestTool
|
||||||
import com.fankes.miui.notify.utils.tool.SystemUITool
|
import com.fankes.miui.notify.utils.tool.SystemUITool
|
||||||
import com.fankes.miui.notify.view.MaterialSwitch
|
|
||||||
import com.google.android.material.radiobutton.MaterialRadioButton
|
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||||
|
|
||||||
class ConfigureActivity : BaseActivity() {
|
class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
||||||
|
|
||||||
/** 当前筛选条件 */
|
/** 当前筛选条件 */
|
||||||
private var filterText = ""
|
private var filterText = ""
|
||||||
@@ -71,9 +64,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
/** 全部的通知优化图标数据 */
|
/** 全部的通知优化图标数据 */
|
||||||
private var iconAllDatas = ArrayList<IconDataBean>()
|
private var iconAllDatas = ArrayList<IconDataBean>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate() {
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_config)
|
|
||||||
/** 检查激活状态 */
|
/** 检查激活状态 */
|
||||||
if (!YukiHookModuleStatus.isActive()) {
|
if (!YukiHookModuleStatus.isActive()) {
|
||||||
showDialog {
|
showDialog {
|
||||||
@@ -85,31 +76,28 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
/** 返回按钮点击事件 */
|
/** 返回按钮点击事件 */
|
||||||
findViewById<View>(R.id.title_back_icon).setOnClickListener { onBackPressed() }
|
binding.titleBackIcon.setOnClickListener { onBackPressed() }
|
||||||
/** 刷新适配器结果相关 */
|
/** 刷新适配器结果相关 */
|
||||||
refreshAdapterResult()
|
refreshAdapterResult()
|
||||||
/** 设置上下按钮点击事件 */
|
/** 设置上下按钮点击事件 */
|
||||||
findViewById<View>(R.id.config_title_up).setOnClickListener {
|
binding.configTitleUp.setOnClickListener {
|
||||||
snake(msg = "滚动到顶部")
|
snake(msg = "滚动到顶部")
|
||||||
onScrollEvent?.invoke(false)
|
onScrollEvent?.invoke(false)
|
||||||
}
|
}
|
||||||
findViewById<View>(R.id.config_title_down).setOnClickListener {
|
binding.configTitleDown.setOnClickListener {
|
||||||
snake(msg = "滚动到底部")
|
snake(msg = "滚动到底部")
|
||||||
onScrollEvent?.invoke(true)
|
onScrollEvent?.invoke(true)
|
||||||
}
|
}
|
||||||
/** 设置过滤按钮点击事件 */
|
/** 设置过滤按钮点击事件 */
|
||||||
findViewById<View>(R.id.config_title_filter).setOnClickListener {
|
binding.configTitleFilter.setOnClickListener {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "按条件过滤"
|
title = "按条件过滤"
|
||||||
var editText: TextInputEditText
|
val editText = bind<DiaIconFilterBinding>().diaIconFilterInputEdit.apply {
|
||||||
addView(R.layout.dia_icon_filter).apply {
|
requestFocus()
|
||||||
editText = findViewById<TextInputEditText>(R.id.dia_icon_filter_input_edit).apply {
|
invalidate()
|
||||||
requestFocus()
|
if (filterText.isNotBlank()) {
|
||||||
invalidate()
|
setText(filterText)
|
||||||
if (filterText.isNotBlank()) {
|
setSelection(filterText.length)
|
||||||
setText(filterText)
|
|
||||||
setSelection(filterText.length)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
confirmButton {
|
confirmButton {
|
||||||
@@ -130,13 +118,11 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 设置同步列表按钮点击事件 */
|
/** 设置同步列表按钮点击事件 */
|
||||||
findViewById<View>(R.id.config_title_sync).setOnClickListener { onStartRefresh() }
|
binding.configTitleSync.setOnClickListener { onStartRefresh() }
|
||||||
/** 设置列表元素和 Adapter */
|
/** 设置列表元素和 Adapter */
|
||||||
findViewById<ListView>(R.id.config_list_view).apply {
|
binding.configListView.apply {
|
||||||
adapter = object : BaseAdapter() {
|
adapter = object : BaseAdapter() {
|
||||||
|
|
||||||
private val inflater = LayoutInflater.from(context)
|
|
||||||
|
|
||||||
override fun getCount() = iconDatas.size
|
override fun getCount() = iconDatas.size
|
||||||
|
|
||||||
override fun getItem(position: Int) = iconDatas[position]
|
override fun getItem(position: Int) = iconDatas[position]
|
||||||
@@ -145,40 +131,33 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||||
var cView = convertView
|
var cView = convertView
|
||||||
val holder: ViewHolder
|
val holder: AdapterConfigBinding
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
holder = ViewHolder()
|
holder = AdapterConfigBinding.inflate(LayoutInflater.from(context))
|
||||||
cView = inflater.inflate(R.layout.adapter_config, null).also {
|
cView = holder.root
|
||||||
holder.appIcon = it.findViewById(R.id.adp_app_icon)
|
|
||||||
holder.appName = it.findViewById(R.id.adp_app_name)
|
|
||||||
holder.pkgName = it.findViewById(R.id.adp_app_pkg_name)
|
|
||||||
holder.cbrName = it.findViewById(R.id.adp_cbr_name)
|
|
||||||
holder.switchOpen = it.findViewById(R.id.adp_app_open_switch)
|
|
||||||
holder.switchAll = it.findViewById(R.id.adp_app_all_switch)
|
|
||||||
}
|
|
||||||
cView.tag = holder
|
cView.tag = holder
|
||||||
} else holder = convertView.tag as ViewHolder
|
} else holder = convertView.tag as AdapterConfigBinding
|
||||||
getItem(position).also {
|
getItem(position).also {
|
||||||
holder.appIcon.setImageBitmap(it.iconBitmap)
|
holder.adpAppIcon.setImageBitmap(it.iconBitmap)
|
||||||
(if (it.iconColor != 0) it.iconColor else resources.getColor(R.color.colorTextGray)).also { color ->
|
(if (it.iconColor != 0) it.iconColor else resources.getColor(R.color.colorTextGray)).also { color ->
|
||||||
holder.appIcon.setColorFilter(color)
|
holder.adpAppIcon.setColorFilter(color)
|
||||||
holder.appName.setTextColor(color)
|
holder.adpAppName.setTextColor(color)
|
||||||
}
|
}
|
||||||
holder.appName.text = it.appName
|
holder.adpAppName.text = it.appName
|
||||||
holder.pkgName.text = it.packageName
|
holder.adpAppPkgName.text = it.packageName
|
||||||
holder.cbrName.text = "贡献者:" + it.contributorName
|
holder.adpCbrName.text = "贡献者:" + it.contributorName
|
||||||
isAppNotifyHookOf(it).also { e ->
|
isAppNotifyHookOf(it).also { e ->
|
||||||
holder.switchOpen.isChecked = e
|
holder.adpAppOpenSwitch.isChecked = e
|
||||||
holder.switchAll.isEnabled = e
|
holder.adpAppAllSwitch.isEnabled = e
|
||||||
}
|
}
|
||||||
holder.switchOpen.setOnCheckedChangeListener { btn, b ->
|
holder.adpAppOpenSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putAppNotifyHookOf(it, b)
|
putAppNotifyHookOf(it, b)
|
||||||
holder.switchAll.isEnabled = b
|
holder.adpAppAllSwitch.isEnabled = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
||||||
}
|
}
|
||||||
holder.switchAll.isChecked = isAppNotifyHookAllOf(it)
|
holder.adpAppAllSwitch.isChecked = isAppNotifyHookAllOf(it)
|
||||||
holder.switchAll.setOnCheckedChangeListener { btn, b ->
|
holder.adpAppAllSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putAppNotifyHookAllOf(it, b)
|
putAppNotifyHookAllOf(it, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
||||||
@@ -186,15 +165,6 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
return cView!!
|
return cView!!
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ViewHolder {
|
|
||||||
lateinit var appIcon: ImageFilterView
|
|
||||||
lateinit var appName: TextView
|
|
||||||
lateinit var pkgName: TextView
|
|
||||||
lateinit var cbrName: TextView
|
|
||||||
lateinit var switchOpen: MaterialSwitch
|
|
||||||
lateinit var switchAll: MaterialSwitch
|
|
||||||
}
|
|
||||||
}.apply {
|
}.apply {
|
||||||
setOnItemLongClickListener { _, _, p, _ ->
|
setOnItemLongClickListener { _, _, p, _ ->
|
||||||
showDialog {
|
showDialog {
|
||||||
@@ -210,7 +180,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
onScrollEvent = { post { setSelection(if (it) iconDatas.lastIndex else 0) } }
|
onScrollEvent = { post { setSelection(if (it) iconDatas.lastIndex else 0) } }
|
||||||
}
|
}
|
||||||
/** 设置点击事件 */
|
/** 设置点击事件 */
|
||||||
findViewById<View>(R.id.config_cbr_button).setOnClickListener {
|
binding.configCbrButton.setOnClickListener {
|
||||||
openBrowser(url = "https://github.com/fankes/AndroidNotifyIconAdapt/blob/main/CONTRIBUTING.md")
|
openBrowser(url = "https://github.com/fankes/AndroidNotifyIconAdapt/blob/main/CONTRIBUTING.md")
|
||||||
}
|
}
|
||||||
/** 装载数据 */
|
/** 装载数据 */
|
||||||
@@ -231,12 +201,8 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
title = "同步列表"
|
title = "同步列表"
|
||||||
var sourceType = modulePrefs.getInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
var sourceType = modulePrefs.getInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
||||||
var customUrl = modulePrefs.getString(SOURCE_SYNC_WAY_CUSTOM_URL)
|
var customUrl = modulePrefs.getString(SOURCE_SYNC_WAY_CUSTOM_URL)
|
||||||
addView(R.layout.dia_source_from).apply {
|
bind<DiaSourceFromBinding>().apply {
|
||||||
val radio1 = findViewById<MaterialRadioButton>(R.id.dia_sf_rd1)
|
diaSfText.apply {
|
||||||
val radio2 = findViewById<MaterialRadioButton>(R.id.dia_sf_rd2)
|
|
||||||
val radio3 = findViewById<MaterialRadioButton>(R.id.dia_sf_rd3)
|
|
||||||
val edLin = findViewById<View>(R.id.dia_sf_text_lin)
|
|
||||||
findViewById<TextInputEditText>(R.id.dia_sf_text).apply {
|
|
||||||
if (customUrl.isNotBlank()) {
|
if (customUrl.isNotBlank()) {
|
||||||
setText(customUrl)
|
setText(customUrl)
|
||||||
setSelection(customUrl.length)
|
setSelection(customUrl.length)
|
||||||
@@ -246,28 +212,28 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
modulePrefs.putString(SOURCE_SYNC_WAY_CUSTOM_URL, text.toString())
|
modulePrefs.putString(SOURCE_SYNC_WAY_CUSTOM_URL, text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
diaSfTextLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
||||||
radio1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1
|
diaSfRd1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1
|
||||||
radio2.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_2
|
diaSfRd2.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_2
|
||||||
radio3.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
diaSfRd3.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
||||||
radio1.setOnClickListener {
|
diaSfRd1.setOnClickListener {
|
||||||
radio2.isChecked = false
|
diaSfRd2.isChecked = false
|
||||||
radio3.isChecked = false
|
diaSfRd3.isChecked = false
|
||||||
edLin.isVisible = false
|
diaSfTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_1
|
sourceType = TYPE_SOURCE_SYNC_WAY_1
|
||||||
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
||||||
}
|
}
|
||||||
radio2.setOnClickListener {
|
diaSfRd2.setOnClickListener {
|
||||||
radio1.isChecked = false
|
diaSfRd1.isChecked = false
|
||||||
radio3.isChecked = false
|
diaSfRd3.isChecked = false
|
||||||
edLin.isVisible = false
|
diaSfTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_2
|
sourceType = TYPE_SOURCE_SYNC_WAY_2
|
||||||
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_2)
|
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_2)
|
||||||
}
|
}
|
||||||
radio3.setOnClickListener {
|
diaSfRd3.setOnClickListener {
|
||||||
radio1.isChecked = false
|
diaSfRd1.isChecked = false
|
||||||
radio2.isChecked = false
|
diaSfRd2.isChecked = false
|
||||||
edLin.isVisible = true
|
diaSfTextLin.isVisible = true
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_3
|
sourceType = TYPE_SOURCE_SYNC_WAY_3
|
||||||
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_3)
|
modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_3)
|
||||||
}
|
}
|
||||||
@@ -289,14 +255,11 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
neutralButton(text = "自定义规则") {
|
neutralButton(text = "自定义规则") {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "自定义规则"
|
title = "自定义规则"
|
||||||
var editText: TextInputEditText
|
val editText = bind<DiaSourceFromStringBinding>().diaSfsInputEdit.apply {
|
||||||
addView(R.layout.dia_source_from_string).apply {
|
requestFocus()
|
||||||
editText = findViewById<TextInputEditText>(R.id.dia_sfs_input_edit).apply {
|
invalidate()
|
||||||
requestFocus()
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
IconPackParams(context = this@ConfigureActivity).also { params ->
|
IconPackParams(context).also { params ->
|
||||||
confirmButton(text = "合并") {
|
confirmButton(text = "合并") {
|
||||||
editText.text.toString().also { jsonString ->
|
editText.text.toString().also { jsonString ->
|
||||||
when {
|
when {
|
||||||
@@ -310,7 +273,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
)
|
)
|
||||||
filterText = ""
|
filterText = ""
|
||||||
mockLocalData()
|
mockLocalData()
|
||||||
SystemUITool.showNeedUpdateApplySnake(context = this@ConfigureActivity)
|
SystemUITool.showNeedUpdateApplySnake(context)
|
||||||
}
|
}
|
||||||
else -> snake(msg = "请输入有效内容")
|
else -> snake(msg = "请输入有效内容")
|
||||||
}
|
}
|
||||||
@@ -324,7 +287,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
params.save(dataJson = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]")
|
params.save(dataJson = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]")
|
||||||
filterText = ""
|
filterText = ""
|
||||||
mockLocalData()
|
mockLocalData()
|
||||||
SystemUITool.showNeedUpdateApplySnake(context = this@ConfigureActivity)
|
SystemUITool.showNeedUpdateApplySnake(context)
|
||||||
}
|
}
|
||||||
else -> snake(msg = "请输入有效内容")
|
else -> snake(msg = "请输入有效内容")
|
||||||
}
|
}
|
||||||
@@ -341,24 +304,15 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
private fun onRefreshing(url: String) = ClientRequestTool.checkingInternetConnect(context = this) {
|
private fun onRefreshing(url: String) = ClientRequestTool.checkingInternetConnect(context = this) {
|
||||||
ProgressDialog(this).apply {
|
showDialog {
|
||||||
setDefaultStyle(context = this@ConfigureActivity)
|
title = "同步中"
|
||||||
setCancelable(false)
|
progressContent = "正在同步 OS 数据"
|
||||||
setTitle("同步中")
|
noCancelable()
|
||||||
setMessage("正在同步 OS 数据")
|
ClientRequestTool.wait(context, url = "$url/OS/MIUI/NotifyIconsSupportConfig.json") { isDone1, ctOS ->
|
||||||
show()
|
progressContent = "正在同步 APP 数据"
|
||||||
}.also {
|
ClientRequestTool.wait(context, url = "$url/APP/NotifyIconsSupportConfig.json") { isDone2, ctAPP ->
|
||||||
ClientRequestTool.wait(
|
cancel()
|
||||||
context = this,
|
IconPackParams(context).also { params ->
|
||||||
url = "$url/OS/MIUI/NotifyIconsSupportConfig.json"
|
|
||||||
) { isDone1, ctOS ->
|
|
||||||
it.setMessage("正在同步 APP 数据")
|
|
||||||
ClientRequestTool.wait(
|
|
||||||
context = this,
|
|
||||||
url = "$url/APP/NotifyIconsSupportConfig.json"
|
|
||||||
) { isDone2, ctAPP ->
|
|
||||||
it.cancel()
|
|
||||||
IconPackParams(context = this).also { params ->
|
|
||||||
if (isDone1 && isDone2) params.splicingJsonArray(ctOS, ctAPP).also {
|
if (isDone1 && isDone2) params.splicingJsonArray(ctOS, ctAPP).also {
|
||||||
when {
|
when {
|
||||||
params.isHackString(it) -> snake(msg = "请求需要验证,请尝试魔法上网或关闭魔法")
|
params.isHackString(it) -> snake(msg = "请求需要验证,请尝试魔法上网或关闭魔法")
|
||||||
@@ -367,7 +321,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
params.save(it)
|
params.save(it)
|
||||||
filterText = ""
|
filterText = ""
|
||||||
mockLocalData()
|
mockLocalData()
|
||||||
SystemUITool.showNeedUpdateApplySnake(context = this)
|
SystemUITool.showNeedUpdateApplySnake(context)
|
||||||
}
|
}
|
||||||
else -> snake(msg = "列表数据已是最新")
|
else -> snake(msg = "列表数据已是最新")
|
||||||
}
|
}
|
||||||
@@ -390,19 +344,13 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
private fun onRefreshingCustom(url: String) = ClientRequestTool.checkingInternetConnect(context = this) {
|
private fun onRefreshingCustom(url: String) = ClientRequestTool.checkingInternetConnect(context = this) {
|
||||||
ProgressDialog(this).apply {
|
showDialog {
|
||||||
setDefaultStyle(context = this@ConfigureActivity)
|
title = "同步中"
|
||||||
setCancelable(false)
|
progressContent = "正在通过自定义地址同步数据"
|
||||||
setTitle("同步中")
|
noCancelable()
|
||||||
setMessage("正在通过自定义地址同步数据")
|
ClientRequestTool.wait(context, url) { isDone, content ->
|
||||||
show()
|
cancel()
|
||||||
}.also {
|
IconPackParams(context).also { params ->
|
||||||
ClientRequestTool.wait(
|
|
||||||
context = this,
|
|
||||||
url = url
|
|
||||||
) { isDone, content ->
|
|
||||||
it.cancel()
|
|
||||||
IconPackParams(context = this).also { params ->
|
|
||||||
if (isDone)
|
if (isDone)
|
||||||
when {
|
when {
|
||||||
params.isHackString(content) -> snake(msg = "请求需要验证,请尝试魔法上网或关闭魔法")
|
params.isHackString(content) -> snake(msg = "请求需要验证,请尝试魔法上网或关闭魔法")
|
||||||
@@ -411,7 +359,7 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
params.save(content)
|
params.save(content)
|
||||||
filterText = ""
|
filterText = ""
|
||||||
mockLocalData()
|
mockLocalData()
|
||||||
SystemUITool.showNeedUpdateApplySnake(context = this)
|
SystemUITool.showNeedUpdateApplySnake(context)
|
||||||
}
|
}
|
||||||
else -> snake(msg = "列表数据已是最新")
|
else -> snake(msg = "列表数据已是最新")
|
||||||
}
|
}
|
||||||
@@ -428,10 +376,10 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
/** 刷新适配器结果相关 */
|
/** 刷新适配器结果相关 */
|
||||||
private fun refreshAdapterResult() {
|
private fun refreshAdapterResult() {
|
||||||
onChanged?.invoke()
|
onChanged?.invoke()
|
||||||
findViewById<TextView>(R.id.config_title_count_text).text =
|
binding.configTitleCountText.text =
|
||||||
if (filterText.isBlank()) "已适配 ${iconDatas.size} 个 APP 的通知图标"
|
if (filterText.isBlank()) "已适配 ${iconDatas.size} 个 APP 的通知图标"
|
||||||
else "“${filterText}” 匹配到 ${iconDatas.size} 个结果"
|
else "“${filterText}” 匹配到 ${iconDatas.size} 个结果"
|
||||||
findViewById<TextView>(R.id.config_list_no_data_view).apply {
|
binding.configListNoDataView.apply {
|
||||||
text = if (iconAllDatas.isEmpty()) "噫,竟然什么都没有~\n请点击右上角同步按钮获取云端数据" else "噫,竟然什么都没找到~"
|
text = if (iconAllDatas.isEmpty()) "噫,竟然什么都没有~\n请点击右上角同步按钮获取云端数据" else "噫,竟然什么都没找到~"
|
||||||
isVisible = iconDatas.isEmpty()
|
isVisible = iconDatas.isEmpty()
|
||||||
}
|
}
|
@@ -22,21 +22,17 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("SetTextI18n")
|
@file:Suppress("SetTextI18n")
|
||||||
|
|
||||||
package com.fankes.miui.notify.ui
|
package com.fankes.miui.notify.ui.activity
|
||||||
|
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
|
||||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
|
||||||
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.BuildConfig
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
|
import com.fankes.miui.notify.databinding.ActivityMainBinding
|
||||||
|
import com.fankes.miui.notify.databinding.DiaStatusIconCountBinding
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_COMPAT
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_HOOK
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_COLOR_ICON_HOOK
|
||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_HIDE_ICON
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_HIDE_ICON
|
||||||
@@ -46,14 +42,13 @@ import com.fankes.miui.notify.hook.HookConst.ENABLE_MODULE_LOG
|
|||||||
import com.fankes.miui.notify.hook.HookConst.ENABLE_NOTIFY_ICON_FIX
|
import com.fankes.miui.notify.hook.HookConst.ENABLE_NOTIFY_ICON_FIX
|
||||||
import com.fankes.miui.notify.hook.HookConst.HOOK_STATUS_ICON_COUNT
|
import com.fankes.miui.notify.hook.HookConst.HOOK_STATUS_ICON_COUNT
|
||||||
import com.fankes.miui.notify.params.IconPackParams
|
import com.fankes.miui.notify.params.IconPackParams
|
||||||
import com.fankes.miui.notify.ui.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.*
|
||||||
import com.fankes.miui.notify.utils.tool.SystemUITool
|
import com.fankes.miui.notify.utils.tool.SystemUITool
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||||
|
|
||||||
class MainActivity : BaseActivity() {
|
class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -61,14 +56,13 @@ class MainActivity : BaseActivity() {
|
|||||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isWarnDialogShowing = false // 警告对话框是否显示
|
/** 警告对话框是否显示 */
|
||||||
|
private var isWarnDialogShowing = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate() {
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_main)
|
|
||||||
/** 设置文本 */
|
/** 设置文本 */
|
||||||
findViewById<TextView>(R.id.main_text_version).text = "模块版本:$moduleVersion"
|
binding.mainTextVersion.text = "模块版本:$moduleVersion"
|
||||||
findViewById<TextView>(R.id.main_text_miui_version).text = "系统版本:$miuiFullVersion"
|
binding.mainTextMiuiVersion.text = "系统版本:$miuiFullVersion"
|
||||||
when {
|
when {
|
||||||
/** 判断是否为 MIUI 系统 */
|
/** 判断是否为 MIUI 系统 */
|
||||||
isNotMIUI ->
|
isNotMIUI ->
|
||||||
@@ -105,7 +99,7 @@ class MainActivity : BaseActivity() {
|
|||||||
title = "配置通知图标优化名单"
|
title = "配置通知图标优化名单"
|
||||||
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
|
msg = "模块需要获取在线规则以更新“通知图标优化名单”,它现在是空的,这看起来是你第一次使用模块,请首先进行配置才可以使用相关功能。\n" +
|
||||||
"你可以随时在本页面下方找到“配置通知图标优化名单”手动前往。"
|
"你可以随时在本页面下方找到“配置通知图标优化名单”手动前往。"
|
||||||
confirmButton(text = "前往") { startActivity(Intent(this@MainActivity, ConfigureActivity::class.java)) }
|
confirmButton(text = "前往") { navigate<ConfigureActivity>() }
|
||||||
cancelButton()
|
cancelButton()
|
||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
@@ -121,55 +115,39 @@ class MainActivity : BaseActivity() {
|
|||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 初始化 View */
|
|
||||||
val moduleEnableSwitch = findViewById<SwitchCompat>(R.id.module_enable_switch)
|
|
||||||
val moduleEnableLogSwitch = findViewById<SwitchCompat>(R.id.module_enable_log_switch)
|
|
||||||
val statusIconCountItem = findViewById<View>(R.id.config_item_s_count_hook)
|
|
||||||
val statusIconCountChildItem = findViewById<View>(R.id.config_item_s_count_child_hook)
|
|
||||||
val statusIconCountSwitch = findViewById<SwitchCompat>(R.id.config_status_icon_count_switch)
|
|
||||||
val statusIconCountText = findViewById<TextView>(R.id.config_status_icon_count_text)
|
|
||||||
val colorIconHookItem = findViewById<View>(R.id.config_item_color_hook)
|
|
||||||
val notifyIconConfigItem = findViewById<View>(R.id.config_item_notify)
|
|
||||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
|
||||||
val colorIconHookSwitch = findViewById<SwitchCompat>(R.id.color_icon_fix_switch)
|
|
||||||
val colorIconCompatSwitch = findViewById<SwitchCompat>(R.id.color_icon_compat_switch)
|
|
||||||
val colorIconCompatText = findViewById<View>(R.id.color_icon_compat_text)
|
|
||||||
val notifyIconFixSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
|
||||||
val notifyIconFixButton = findViewById<View>(R.id.config_notify_app_button)
|
|
||||||
|
|
||||||
/** 获取 Sp 存储的信息 */
|
/** 获取 Sp 存储的信息 */
|
||||||
var statusBarIconCount = modulePrefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
var statusBarIconCount = modulePrefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
||||||
colorIconHookItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.colorIconHookItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
statusIconCountItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.statusIconCountItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
colorIconCompatSwitch.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
binding.colorIconCompatSwitch.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
colorIconCompatText.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
binding.colorIconCompatText.isVisible = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
notifyIconConfigItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true) &&
|
binding.notifyIconConfigItem.isVisible = modulePrefs.getBoolean(ENABLE_MODULE, default = true) &&
|
||||||
modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
notifyIconFixButton.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
binding.notifyIconFixButton.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||||
statusIconCountSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
binding.statusIconCountSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
||||||
statusIconCountChildItem.isVisible = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
binding.statusIconCountChildItem.isVisible = modulePrefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true)
|
||||||
moduleEnableSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
binding.moduleEnableSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||||
moduleEnableLogSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE_LOG, default = false)
|
binding.moduleEnableLogSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE_LOG, default = false)
|
||||||
hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
||||||
colorIconHookSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
binding.colorIconHookSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
colorIconCompatSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_COMPAT)
|
binding.colorIconCompatSwitch.isChecked = modulePrefs.getBoolean(ENABLE_COLOR_ICON_COMPAT)
|
||||||
notifyIconFixSwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
binding.notifyIconFixSwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||||
statusIconCountText.text = statusBarIconCount.toString()
|
binding.statusIconCountText.text = statusBarIconCount.toString()
|
||||||
moduleEnableSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.moduleEnableSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_MODULE, b)
|
modulePrefs.putBoolean(ENABLE_MODULE, b)
|
||||||
moduleEnableLogSwitch.isVisible = b
|
binding.moduleEnableLogSwitch.isVisible = b
|
||||||
colorIconHookItem.isVisible = b
|
binding.colorIconHookItem.isVisible = b
|
||||||
statusIconCountItem.isVisible = b
|
binding.statusIconCountItem.isVisible = b
|
||||||
notifyIconConfigItem.isVisible = b && colorIconHookSwitch.isChecked
|
binding.notifyIconConfigItem.isVisible = b && binding.colorIconHookSwitch.isChecked
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_MODULE_LOG, b)
|
modulePrefs.putBoolean(ENABLE_MODULE_LOG, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_HIDE_ICON, b)
|
modulePrefs.putBoolean(ENABLE_HIDE_ICON, b)
|
||||||
packageManager.setComponentEnabledSetting(
|
packageManager.setComponentEnabledSetting(
|
||||||
@@ -178,47 +156,44 @@ class MainActivity : BaseActivity() {
|
|||||||
PackageManager.DONT_KILL_APP
|
PackageManager.DONT_KILL_APP
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
statusIconCountSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.statusIconCountSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, b)
|
modulePrefs.putBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, b)
|
||||||
statusIconCountChildItem.isVisible = b
|
binding.statusIconCountChildItem.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
colorIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.colorIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_COLOR_ICON_HOOK, b)
|
modulePrefs.putBoolean(ENABLE_COLOR_ICON_HOOK, b)
|
||||||
notifyIconConfigItem.isVisible = b
|
binding.notifyIconConfigItem.isVisible = b
|
||||||
colorIconCompatSwitch.isVisible = b
|
binding.colorIconCompatSwitch.isVisible = b
|
||||||
colorIconCompatText.isVisible = b
|
binding.colorIconCompatText.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_COLOR_ICON_COMPAT, b)
|
modulePrefs.putBoolean(ENABLE_COLOR_ICON_COMPAT, b)
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconFixSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX, b)
|
modulePrefs.putBoolean(ENABLE_NOTIFY_ICON_FIX, b)
|
||||||
notifyIconFixButton.isVisible = b
|
binding.notifyIconFixButton.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
notifyIconFixButton.setOnClickListener { startActivity(Intent(this, ConfigureActivity::class.java)) }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
/** 设置警告 */
|
/** 设置警告 */
|
||||||
findViewById<View>(R.id.config_warn_s_count_dis_tip).isGone = miuiVersionCode > 12.5
|
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
|
||||||
/** 修改状态栏通知图标个数按钮点击事件 */
|
/** 修改状态栏通知图标个数按钮点击事件 */
|
||||||
findViewById<View>(R.id.config_status_icon_count_button).setOnClickListener {
|
binding.statusIconCountButton.setOnClickListener {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "设置最多显示的图标个数"
|
title = "设置最多显示的图标个数"
|
||||||
var editText: TextInputEditText
|
val editText = bind<DiaStatusIconCountBinding>().diaStatusIconCountInputEdit.apply {
|
||||||
addView(R.layout.dia_status_icon_count).apply {
|
requestFocus()
|
||||||
editText = findViewById<TextInputEditText>(R.id.dia_status_icon_count_input_edit).apply {
|
invalidate()
|
||||||
requestFocus()
|
setText(statusBarIconCount.toString())
|
||||||
invalidate()
|
setSelection(statusBarIconCount.toString().length)
|
||||||
setText(statusBarIconCount.toString())
|
|
||||||
setSelection(statusBarIconCount.toString().length)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
confirmButton {
|
confirmButton {
|
||||||
when {
|
when {
|
||||||
@@ -227,8 +202,8 @@ class MainActivity : BaseActivity() {
|
|||||||
editText.text.toString().isNotBlank() -> runCatching {
|
editText.text.toString().isNotBlank() -> runCatching {
|
||||||
statusBarIconCount = editText.text.toString().trim().toInt()
|
statusBarIconCount = editText.text.toString().trim().toInt()
|
||||||
modulePrefs.putInt(HOOK_STATUS_ICON_COUNT, statusBarIconCount)
|
modulePrefs.putInt(HOOK_STATUS_ICON_COUNT, statusBarIconCount)
|
||||||
statusIconCountText.text = statusBarIconCount.toString()
|
binding.statusIconCountText.text = statusBarIconCount.toString()
|
||||||
SystemUITool.showNeedRestartSnake(context = this@MainActivity)
|
SystemUITool.showNeedRestartSnake(context)
|
||||||
}.onFailure { snake(msg = "数值格式无效") }
|
}.onFailure { snake(msg = "数值格式无效") }
|
||||||
else -> snake(msg = "请输入有效数值")
|
else -> snake(msg = "请输入有效数值")
|
||||||
}
|
}
|
||||||
@@ -237,33 +212,33 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 重启按钮点击事件 */
|
/** 重启按钮点击事件 */
|
||||||
findViewById<View>(R.id.title_restart_icon).setOnClickListener { SystemUITool.restartSystemUI(context = this) }
|
binding.titleRestartIcon.setOnClickListener { SystemUITool.restartSystemUI(context = this) }
|
||||||
/** 项目地址按钮点击事件 */
|
/** 项目地址按钮点击事件 */
|
||||||
findViewById<View>(R.id.title_github_icon).setOnClickListener {
|
binding.titleGithubIcon.setOnClickListener {
|
||||||
openBrowser(url = "https://github.com/fankes/MIUINativeNotifyIcon")
|
openBrowser(url = "https://github.com/fankes/MIUINativeNotifyIcon")
|
||||||
}
|
}
|
||||||
/** 恰饭! */
|
/** 恰饭! */
|
||||||
findViewById<View>(R.id.link_with_follow_me).setOnClickListener {
|
binding.linkWithFollowMe.setOnClickListener {
|
||||||
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 刷新模块状态 */
|
/** 刷新模块状态 */
|
||||||
private fun refreshModuleStatus() {
|
private fun refreshModuleStatus() {
|
||||||
findViewById<LinearLayout>(R.id.main_lin_status).setBackgroundResource(
|
binding.mainLinStatus.setBackgroundResource(
|
||||||
when {
|
when {
|
||||||
YukiHookModuleStatus.isActive() && isMiuiNotifyStyle -> R.drawable.bg_yellow_round
|
YukiHookModuleStatus.isActive() && isMiuiNotifyStyle -> R.drawable.bg_yellow_round
|
||||||
YukiHookModuleStatus.isActive() -> R.drawable.bg_green_round
|
YukiHookModuleStatus.isActive() -> R.drawable.bg_green_round
|
||||||
else -> R.drawable.bg_dark_round
|
else -> R.drawable.bg_dark_round
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
findViewById<ImageFilterView>(R.id.main_img_status).setImageResource(
|
binding.mainImgStatus.setImageResource(
|
||||||
when {
|
when {
|
||||||
YukiHookModuleStatus.isActive() && !isMiuiNotifyStyle -> R.mipmap.ic_success
|
YukiHookModuleStatus.isActive() && !isMiuiNotifyStyle -> R.mipmap.ic_success
|
||||||
else -> R.mipmap.ic_warn
|
else -> R.mipmap.ic_warn
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
findViewById<TextView>(R.id.main_text_status).text =
|
binding.mainTextStatus.text =
|
||||||
when {
|
when {
|
||||||
YukiHookModuleStatus.isActive() && isMiuiNotifyStyle -> "模块已激活,但未在工作"
|
YukiHookModuleStatus.isActive() && isMiuiNotifyStyle -> "模块已激活,但未在工作"
|
||||||
YukiHookModuleStatus.isActive() -> "模块已激活"
|
YukiHookModuleStatus.isActive() -> "模块已激活"
|
@@ -20,18 +20,36 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/30.
|
* This file is Created by fankes on 2022/1/30.
|
||||||
*/
|
*/
|
||||||
package com.fankes.miui.notify.ui.base
|
@file:Suppress("UNCHECKED_CAST")
|
||||||
|
|
||||||
|
package com.fankes.miui.notify.ui.activity.base
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
import com.fankes.miui.notify.utils.factory.isNotSystemInDarkMode
|
import com.fankes.miui.notify.utils.factory.isNotSystemInDarkMode
|
||||||
import com.gyf.immersionbar.ktx.immersionBar
|
import com.gyf.immersionbar.ktx.immersionBar
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
||||||
|
import java.lang.reflect.ParameterizedType
|
||||||
|
|
||||||
abstract class BaseActivity : AppCompatActivity() {
|
abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||||
|
|
||||||
|
/** 获取绑定布局对象 */
|
||||||
|
lateinit var binding: VB
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
javaClass.genericSuperclass.also { type ->
|
||||||
|
if (type is ParameterizedType) {
|
||||||
|
binding = (type.actualTypeArguments[0] as Class<VB>).method {
|
||||||
|
name = "inflate"
|
||||||
|
param(LayoutInflaterClass)
|
||||||
|
}.get().invoke<VB>(layoutInflater) ?: error("binding failed")
|
||||||
|
setContentView(binding.root)
|
||||||
|
} else error("binding but got wrong type")
|
||||||
|
}
|
||||||
/** 隐藏系统的标题栏 */
|
/** 隐藏系统的标题栏 */
|
||||||
supportActionBar?.hide()
|
supportActionBar?.hide()
|
||||||
/** 初始化沉浸状态栏 */
|
/** 初始化沉浸状态栏 */
|
||||||
@@ -43,5 +61,10 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||||||
navigationBarDarkIcon(isNotSystemInDarkMode)
|
navigationBarDarkIcon(isNotSystemInDarkMode)
|
||||||
fitsSystemWindows(true)
|
fitsSystemWindows(true)
|
||||||
}
|
}
|
||||||
|
/** 装载子类 */
|
||||||
|
onCreate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 回调 [onCreate] 方法 */
|
||||||
|
abstract fun onCreate()
|
||||||
}
|
}
|
@@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("SameParameterValue")
|
@file:Suppress("SameParameterValue")
|
||||||
|
|
||||||
package com.fankes.miui.notify.view
|
package com.fankes.miui.notify.ui.view
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
@@ -20,94 +20,182 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/7.
|
* This file is Created by fankes on 2022/1/7.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("unused", "DEPRECATION")
|
@file:Suppress("unused", "OPT_IN_USAGE", "EXPERIMENTAL_API_USAGE")
|
||||||
|
|
||||||
package com.fankes.miui.notify.utils.factory
|
package com.fankes.miui.notify.utils.factory
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.DisplayMetrics
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.ViewGroup
|
||||||
import kotlin.math.round
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.highcapable.yukihookapi.annotation.DoNotUseField
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造对话框
|
* 构造对话框
|
||||||
|
* @param isUseBlackTheme 是否使用深色主题
|
||||||
* @param it 对话框方法体
|
* @param it 对话框方法体
|
||||||
*/
|
*/
|
||||||
fun Context.showDialog(it: DialogBuilder.() -> Unit) = DialogBuilder(this).apply(it).show()
|
fun Context.showDialog(isUseBlackTheme: Boolean = false, it: DialogBuilder.() -> Unit) =
|
||||||
|
DialogBuilder(this, isUseBlackTheme).apply(it).show()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话框构造器
|
* 对话框构造器
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
|
* @param isUseBlackTheme 是否使用深色主题 - 对 AndroidX 风格无效
|
||||||
*/
|
*/
|
||||||
class DialogBuilder(private val context: Context) {
|
class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean) {
|
||||||
|
|
||||||
private var instance: AlertDialog.Builder? = null // 实例对象
|
private var instanceAndroidX: androidx.appcompat.app.AlertDialog.Builder? = null // 实例对象
|
||||||
|
private var instanceAndroid: android.app.AlertDialog.Builder? = null // 实例对象
|
||||||
|
|
||||||
private var customLayoutView: View? = null // 自定义布局
|
private var dialogInstance: Dialog? = null // 对话框实例
|
||||||
|
|
||||||
|
@DoNotUseField
|
||||||
|
var customLayoutView: View? = null // 自定义布局
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要使用 AndroidX 风格对话框
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
private val isUsingAndroidX get() = runCatching { context is AppCompatActivity }.getOrNull() ?: false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
instance = AlertDialog.Builder(context, android.R.style.Theme_Material_Light_Dialog)
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX = MaterialAlertDialogBuilder(context) }
|
||||||
|
else runCatching {
|
||||||
|
instanceAndroid = android.app.AlertDialog.Builder(
|
||||||
|
context,
|
||||||
|
if (isUseBlackTheme) android.R.style.Theme_Material_Dialog else android.R.style.Theme_Material_Light_Dialog
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置对话框不可关闭 */
|
/** 设置对话框不可关闭 */
|
||||||
fun noCancelable() = instance?.setCancelable(false)
|
fun noCancelable() {
|
||||||
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setCancelable(false) }
|
||||||
|
else runCatching { instanceAndroid?.setCancelable(false) }
|
||||||
|
}
|
||||||
|
|
||||||
/** 设置对话框标题 */
|
/** 设置对话框标题 */
|
||||||
var title
|
var title
|
||||||
get() = ""
|
get() = ""
|
||||||
set(value) {
|
set(value) {
|
||||||
instance?.setTitle(value)
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setTitle(value) }
|
||||||
|
else runCatching { instanceAndroid?.setTitle(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置对话框消息内容 */
|
/** 设置对话框消息内容 */
|
||||||
var msg
|
var msg
|
||||||
get() = ""
|
get() = ""
|
||||||
set(value) {
|
set(value) {
|
||||||
instance?.setMessage(value)
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setMessage(value) }
|
||||||
|
else runCatching { instanceAndroid?.setMessage(value) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置进度条对话框消息内容 */
|
||||||
|
var progressContent
|
||||||
|
get() = ""
|
||||||
|
set(value) {
|
||||||
|
if (customLayoutView == null)
|
||||||
|
customLayoutView = LinearLayout(context).apply {
|
||||||
|
orientation = LinearLayout.HORIZONTAL
|
||||||
|
gravity = Gravity.CENTER or Gravity.START
|
||||||
|
addView(ProgressBar(context))
|
||||||
|
addView(View(context).apply { layoutParams = ViewGroup.LayoutParams(20.dp(context), 5) })
|
||||||
|
addView(TextView(context).apply {
|
||||||
|
tag = "progressContent"
|
||||||
|
text = value
|
||||||
|
})
|
||||||
|
setPadding(20.dp(context), 20.dp(context), 20.dp(context), 20.dp(context))
|
||||||
|
}
|
||||||
|
else customLayoutView?.findViewWithTag<TextView>("progressContent")?.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置对话框自定义布局
|
* 设置对话框自定义布局
|
||||||
* @param resId 属性资源 Id
|
* @return [ViewBinding]
|
||||||
* @return [View]
|
|
||||||
*/
|
*/
|
||||||
fun addView(resId: Int): View {
|
inline fun <reified T : ViewBinding> bind() =
|
||||||
customLayoutView = LayoutInflater.from(context).inflate(resId, null)
|
T::class.java.method {
|
||||||
return customLayoutView ?: error("Inflate $resId failed")
|
name = "inflate"
|
||||||
}
|
param(LayoutInflaterClass)
|
||||||
|
}.get().invoke<T>(LayoutInflater.from(context))?.apply {
|
||||||
|
customLayoutView = root
|
||||||
|
} ?: error("binding failed")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置对话框确定按钮
|
* 设置对话框确定按钮
|
||||||
* @param text 按钮文本内容
|
* @param text 按钮文本内容
|
||||||
* @param it 点击事件
|
* @param it 点击事件
|
||||||
*/
|
*/
|
||||||
fun confirmButton(text: String = "确定", it: () -> Unit = {}) =
|
fun confirmButton(text: String = "确定", it: () -> Unit = {}) {
|
||||||
instance?.setPositiveButton(text) { _, _ -> it() }
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setPositiveButton(text) { _, _ -> it() } }
|
||||||
|
else runCatching { instanceAndroid?.setPositiveButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置对话框取消按钮
|
* 设置对话框取消按钮
|
||||||
* @param text 按钮文本内容
|
* @param text 按钮文本内容
|
||||||
* @param it 点击事件
|
* @param it 点击事件
|
||||||
*/
|
*/
|
||||||
fun cancelButton(text: String = "取消", it: () -> Unit = {}) =
|
fun cancelButton(text: String = "取消", it: () -> Unit = {}) {
|
||||||
instance?.setNegativeButton(text) { _, _ -> it() }
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setNegativeButton(text) { _, _ -> it() } }
|
||||||
|
else runCatching { instanceAndroid?.setNegativeButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置对话框第三个按钮
|
* 设置对话框第三个按钮
|
||||||
* @param text 按钮文本内容
|
* @param text 按钮文本内容
|
||||||
* @param it 点击事件
|
* @param it 点击事件
|
||||||
*/
|
*/
|
||||||
fun neutralButton(text: String = "更多", it: () -> Unit = {}) =
|
fun neutralButton(text: String = "更多", it: () -> Unit = {}) {
|
||||||
instance?.setNeutralButton(text) { _, _ -> it() }
|
if (isUsingAndroidX)
|
||||||
|
runCatching { instanceAndroidX?.setNeutralButton(text) { _, _ -> it() } }
|
||||||
|
else runCatching { instanceAndroid?.setNeutralButton(text) { _, _ -> it() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消对话框 */
|
||||||
|
fun cancel() = dialogInstance?.cancel()
|
||||||
|
|
||||||
/** 显示对话框 */
|
/** 显示对话框 */
|
||||||
internal fun show() = instance?.create()?.apply {
|
internal fun show() {
|
||||||
val dm = DisplayMetrics()
|
if (isUsingAndroidX) runCatching {
|
||||||
(context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(dm)
|
instanceAndroidX?.create()?.apply {
|
||||||
customLayoutView?.let { setView(it.apply { minimumWidth = round(x = dm.widthPixels / 1.3).toInt() }) }
|
customLayoutView?.let { setView(it) }
|
||||||
setDefaultStyle(context = this@DialogBuilder.context)
|
dialogInstance = this
|
||||||
}?.show()
|
}?.show()
|
||||||
|
} else runCatching {
|
||||||
|
instanceAndroid?.create()?.apply {
|
||||||
|
customLayoutView?.let { setView(it) }
|
||||||
|
window?.setBackgroundDrawable(
|
||||||
|
GradientDrawable(
|
||||||
|
GradientDrawable.Orientation.TOP_BOTTOM,
|
||||||
|
if (isUseBlackTheme) intArrayOf(0xFF2D2D2D.toInt(), 0xFF2D2D2D.toInt())
|
||||||
|
else intArrayOf(Color.WHITE, Color.WHITE)
|
||||||
|
).apply {
|
||||||
|
shape = GradientDrawable.RECTANGLE
|
||||||
|
gradientType = GradientDrawable.LINEAR_GRADIENT
|
||||||
|
cornerRadius = 15.dpFloat(this@DialogBuilder.context)
|
||||||
|
})
|
||||||
|
dialogInstance = this
|
||||||
|
}?.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,6 @@
|
|||||||
package com.fankes.miui.notify.utils.factory
|
package com.fankes.miui.notify.utils.factory
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -36,7 +35,6 @@ import android.content.res.Configuration
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.GradientDrawable
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
@@ -51,7 +49,6 @@ import com.highcapable.yukihookapi.hook.type.java.StringType
|
|||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统深色模式是否开启
|
* 系统深色模式是否开启
|
||||||
* @return [Boolean] 是否开启
|
* @return [Boolean] 是否开启
|
||||||
@@ -278,21 +275,6 @@ val ByteArray.bitmap: Bitmap get() = BitmapFactory.decodeByteArray(this, 0, size
|
|||||||
*/
|
*/
|
||||||
val String.bitmap: Bitmap get() = unbase64.bitmap
|
val String.bitmap: Bitmap get() = unbase64.bitmap
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置对话框默认风格
|
|
||||||
* @param context 使用的实例
|
|
||||||
*/
|
|
||||||
fun AlertDialog.setDefaultStyle(context: Context) =
|
|
||||||
window?.setBackgroundDrawable(
|
|
||||||
GradientDrawable(
|
|
||||||
GradientDrawable.Orientation.TOP_BOTTOM,
|
|
||||||
intArrayOf(Color.WHITE, Color.WHITE)
|
|
||||||
).apply {
|
|
||||||
shape = GradientDrawable.RECTANGLE
|
|
||||||
gradientType = GradientDrawable.LINEAR_GRADIENT
|
|
||||||
cornerRadius = 15.dpFloat(context)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统 Prop 值
|
* 获取系统 Prop 值
|
||||||
* @param key Key
|
* @param key Key
|
||||||
@@ -323,6 +305,13 @@ fun execShellSu(cmd: String) = safeOfNothing {
|
|||||||
*/
|
*/
|
||||||
fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show()
|
fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到指定页面
|
||||||
|
*
|
||||||
|
* [T] 为指定的 [Activity]
|
||||||
|
*/
|
||||||
|
inline fun <reified T : Activity> Context.navigate() = startActivity(Intent(this, T::class.java))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 弹出 [Snackbar]
|
* 弹出 [Snackbar]
|
||||||
* @param msg 提示内容
|
* @param msg 提示内容
|
||||||
|
@@ -25,12 +25,11 @@
|
|||||||
package com.fankes.miui.notify.utils.tool
|
package com.fankes.miui.notify.utils.tool
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.ProgressDialog
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import com.fankes.miui.notify.utils.factory.safeOfNull
|
import com.fankes.miui.notify.utils.factory.safeOfNull
|
||||||
import com.fankes.miui.notify.utils.factory.setDefaultStyle
|
|
||||||
import com.fankes.miui.notify.utils.factory.showDialog
|
import com.fankes.miui.notify.utils.factory.showDialog
|
||||||
import com.fankes.miui.notify.utils.factory.snake
|
import com.fankes.miui.notify.utils.factory.snake
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
@@ -50,13 +49,11 @@ object ClientRequestTool {
|
|||||||
* @param context 实例
|
* @param context 实例
|
||||||
* @param it 已连接回调
|
* @param it 已连接回调
|
||||||
*/
|
*/
|
||||||
fun checkingInternetConnect(context: Activity, it: () -> Unit) =
|
fun checkingInternetConnect(context: Context, it: () -> Unit) =
|
||||||
ProgressDialog(context).apply {
|
context.showDialog {
|
||||||
setDefaultStyle(context)
|
title = "准备中"
|
||||||
setCancelable(false)
|
progressContent = "正在检查网络连接情况"
|
||||||
setTitle("准备中")
|
noCancelable()
|
||||||
setMessage("正在检查网络连接情况")
|
|
||||||
}.apply {
|
|
||||||
wait(context, url = "https://www.baidu.com") { isDone, _ ->
|
wait(context, url = "https://www.baidu.com") { isDone, _ ->
|
||||||
cancel()
|
cancel()
|
||||||
if (isDone) it() else
|
if (isDone) it() else
|
||||||
@@ -75,7 +72,7 @@ object ClientRequestTool {
|
|||||||
cancelButton()
|
cancelButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.show()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送 GET 请求内容并等待
|
* 发送 GET 请求内容并等待
|
||||||
@@ -83,7 +80,7 @@ object ClientRequestTool {
|
|||||||
* @param url 请求地址
|
* @param url 请求地址
|
||||||
* @param it 回调 - ([Boolean] 是否成功,[String] 成功的内容或失败消息)
|
* @param it 回调 - ([Boolean] 是否成功,[String] 成功的内容或失败消息)
|
||||||
*/
|
*/
|
||||||
fun wait(context: Activity, url: String, it: (Boolean, String) -> Unit) = runCatching {
|
fun wait(context: Context, url: String, it: (Boolean, String) -> Unit) = runCatching {
|
||||||
OkHttpClient().newBuilder().apply {
|
OkHttpClient().newBuilder().apply {
|
||||||
SSLSocketClient.sSLSocketFactory?.let { sslSocketFactory(it, SSLSocketClient.trustManager) }
|
SSLSocketClient.sSLSocketFactory?.let { sslSocketFactory(it, SSLSocketClient.trustManager) }
|
||||||
hostnameVerifier(SSLSocketClient.hostnameVerifier)
|
hostnameVerifier(SSLSocketClient.hostnameVerifier)
|
||||||
@@ -94,12 +91,12 @@ object ClientRequestTool {
|
|||||||
.build()
|
.build()
|
||||||
).enqueue(object : Callback {
|
).enqueue(object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
context.runOnUiThread { it(false, e.toString()) }
|
(context as? Activity?)?.runOnUiThread { it(false, e.toString()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) {
|
override fun onResponse(call: Call, response: Response) {
|
||||||
val bodyString = response.body?.string() ?: ""
|
val bodyString = response.body?.string() ?: ""
|
||||||
context.runOnUiThread { it(true, bodyString) }
|
(context as? Activity?)?.runOnUiThread { it(true, bodyString) }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}.onFailure { it(false, "URL 无效") }
|
}.onFailure { it(false, "URL 无效") }
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/colorThemeBackground"
|
android:background="@color/colorThemeBackground"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.MainActivity"
|
tools:context=".ui.activity.MainActivity"
|
||||||
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription">
|
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/colorThemeBackground"
|
android:background="@color/colorThemeBackground"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.MainActivity"
|
tools:context=".ui.activity.MainActivity"
|
||||||
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription">
|
tools:ignore="HardcodedText,UseCompoundDrawables,ContentDescription">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/module_enable_switch"
|
android:id="@+id/module_enable_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/module_enable_log_switch"
|
android:id="@+id/module_enable_log_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/config_item_s_count_hook"
|
android:id="@+id/status_icon_count_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
@@ -215,8 +215,8 @@
|
|||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/config_status_icon_count_switch"
|
android:id="@+id/status_icon_count_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="解除状态栏通知图标个数限制"
|
android:text="解除状态栏通知图标个数限制"
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/config_warn_s_count_dis_tip"
|
android:id="@+id/warn_s_count_dis_tip"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/config_item_s_count_child_hook"
|
android:id="@+id/status_icon_count_child_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/config_status_icon_count_text"
|
android:id="@+id/status_icon_count_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
@@ -294,7 +294,7 @@
|
|||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/config_status_icon_count_button"
|
android:id="@+id/status_icon_count_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bg_button_round"
|
android:background="@drawable/bg_button_round"
|
||||||
@@ -312,7 +312,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/config_item_color_hook"
|
android:id="@+id/color_icon_hook_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
@@ -325,8 +325,8 @@
|
|||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/color_icon_fix_switch"
|
android:id="@+id/color_icon_hook_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="忽略彩色通知图标"
|
android:text="忽略彩色通知图标"
|
||||||
@@ -343,7 +343,7 @@
|
|||||||
android:textColor="@color/colorTextDark"
|
android:textColor="@color/colorTextDark"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
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="35dp"
|
android:layout_height="35dp"
|
||||||
@@ -365,7 +365,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/config_item_notify"
|
android:id="@+id/notify_icon_config_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
@@ -379,7 +379,7 @@
|
|||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/notify_icon_fix_switch"
|
android:id="@+id/notify_icon_fix_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -390,7 +390,7 @@
|
|||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/config_notify_app_button"
|
android:id="@+id/notify_icon_fix_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
@@ -440,7 +440,7 @@
|
|||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/hide_icon_in_launcher_switch"
|
android:id="@+id/hide_icon_in_launcher_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/adp_app_open_switch"
|
android:id="@+id/adp_app_open_switch"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
<com.fankes.miui.notify.view.MaterialSwitch
|
<com.fankes.miui.notify.ui.view.MaterialSwitch
|
||||||
android:id="@+id/adp_app_all_switch"
|
android:id="@+id/adp_app_all_switch"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.MIUINativeNotifyIcon" parent="Theme.Material3.DayNight">
|
<style name="Theme.MIUINativeNotifyIcon" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
@@ -1,4 +1,4 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.MIUINativeNotifyIcon" parent="Theme.Material3.DayNight">
|
<style name="Theme.MIUINativeNotifyIcon" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
Reference in New Issue
Block a user