mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-04 09:45:44 +08:00
更新通知图标优化名单功能并优化代码和相关功能
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -10,6 +10,7 @@
|
||||
<entry key="app/src/main/res/drawable/white_round.xml" value="0.256" />
|
||||
<entry key="app/src/main/res/layout/activity_config.xml" value="0.42168674698795183" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.4036346245815399" />
|
||||
<entry key="app/src/main/res/layout/adapter_config.xml" value="0.4375" />
|
||||
<entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.44871794871794873" />
|
||||
</map>
|
||||
</option>
|
||||
|
@@ -18,12 +18,23 @@
|
||||
*
|
||||
* This file is Created by fankes on 2022/01/30.
|
||||
*/
|
||||
@file:Suppress("SetTextI18n", "InflateParams")
|
||||
|
||||
package com.fankes.miui.notify.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.ListView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
import com.fankes.miui.notify.R
|
||||
import com.fankes.miui.notify.hook.HookMedium
|
||||
import com.fankes.miui.notify.params.IconPackParams
|
||||
import com.fankes.miui.notify.ui.base.BaseActivity
|
||||
import com.fankes.miui.notify.view.MaterialSwitch
|
||||
|
||||
class ConfigureActivity : BaseActivity() {
|
||||
|
||||
@@ -32,5 +43,54 @@ class ConfigureActivity : BaseActivity() {
|
||||
setContentView(R.layout.activity_config)
|
||||
/** 返回按钮点击事件 */
|
||||
findViewById<View>(R.id.title_back_icon).setOnClickListener { onBackPressed() }
|
||||
/** 设置列表元素和 Adapter */
|
||||
findViewById<ListView>(R.id.config_list_view).apply {
|
||||
adapter = object : BaseAdapter() {
|
||||
|
||||
private val inflater = LayoutInflater.from(context)
|
||||
|
||||
override fun getCount() = IconPackParams.iconDatas.size
|
||||
|
||||
override fun getItem(position: Int) = IconPackParams.iconDatas[position]
|
||||
|
||||
override fun getItemId(position: Int) = position.toLong()
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||
var cView = convertView
|
||||
val holder: ViewHolder
|
||||
if (convertView == null) {
|
||||
holder = ViewHolder()
|
||||
cView = inflater.inflate(R.layout.adapter_config, null).also {
|
||||
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.switch = it.findViewById(R.id.adp_app_switch)
|
||||
}
|
||||
cView.tag = holder
|
||||
} else holder = convertView.tag as ViewHolder
|
||||
getItem(position).also {
|
||||
holder.appIcon.setImageBitmap(it.iconBitmap)
|
||||
holder.appName.text = it.appName
|
||||
holder.pkgName.text = it.packageName
|
||||
holder.cbrName.text = "贡献者:" + it.contributorName
|
||||
holder.switch.isChecked = HookMedium.isAppNotifyHookOf(it.packageName)
|
||||
holder.switch.setOnCheckedChangeListener { btn, b ->
|
||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||
HookMedium.putAppNotifyHookOf(it.packageName, b)
|
||||
}
|
||||
}
|
||||
return cView!!
|
||||
}
|
||||
|
||||
inner class ViewHolder {
|
||||
lateinit var appIcon: ImageFilterView
|
||||
lateinit var appName: TextView
|
||||
lateinit var pkgName: TextView
|
||||
lateinit var cbrName: TextView
|
||||
lateinit var switch: MaterialSwitch
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,7 +23,8 @@
|
||||
style="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:src="@mipmap/back"
|
||||
android:tint="@color/colorTextGray" />
|
||||
|
||||
@@ -38,5 +39,44 @@
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/permotion_round"
|
||||
android:elevation="0dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="15dp">
|
||||
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:alpha="0.85"
|
||||
android:src="@mipmap/about"
|
||||
android:tint="@color/colorTextDark" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="5dp"
|
||||
android:text="开启或关闭指定 APP 的设置将在切换界面后生效。"
|
||||
android:textColor="@color/colorTextGray"
|
||||
android:textSize="11sp"
|
||||
tools:ignore="SmallSp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/config_list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@color/trans"
|
||||
android:dividerHeight="5dp"
|
||||
android:listSelector="@null"
|
||||
android:padding="15dp"
|
||||
android:scrollbars="none" />
|
||||
</LinearLayout>
|
72
app/src/main/res/layout/adapter_config.xml
Normal file
72
app/src/main/res/layout/adapter_config.xml
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/permotion_round"
|
||||
android:gravity="center|start"
|
||||
android:orientation="horizontal"
|
||||
android:padding="15dp"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center|start"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center|start">
|
||||
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:id="@+id/adp_app_icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:alpha="0.85"
|
||||
android:src="@mipmap/about"
|
||||
android:tint="@color/colorTextGray" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/adp_app_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.85"
|
||||
android:singleLine="true"
|
||||
android:text="APP 名称"
|
||||
android:textColor="@color/colorTextGray"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/adp_app_pkg_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.75"
|
||||
android:singleLine="true"
|
||||
android:text="com.xxx.xxx"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/adp_cbr_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="贡献者:noname"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.fankes.miui.notify.view.MaterialSwitch
|
||||
android:id="@+id/adp_app_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/colorTextGray"
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
BIN
app/src/main/res/mipmap-xxhdpi/back.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
@@ -7,4 +7,5 @@
|
||||
<color name="teal_700">#656565</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="trans">#00000000</color>
|
||||
</resources>
|
Reference in New Issue
Block a user