-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加平行小窗的判断逻辑,减少无限添加应用导致内存过多的可能,减少应用加载 去除悬浮球的平行小窗适配
- Loading branch information
Showing
19 changed files
with
560 additions
and
217 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.liuyi.mifreeformx | ||
|
||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData | ||
import org.liuyi.mifreeformx.bean.BlackListBean | ||
|
||
/** | ||
* @Author: Liuyi | ||
* @Date: 2023/05/09/9:47:41 | ||
* @Description: | ||
*/ | ||
|
||
|
||
object BlackList { | ||
|
||
object AppJumpSourceBlacklist : | ||
BlackListBean(PrefsData("app_jump_source_blacklist", setOf("com.android.providers.media.module"))) | ||
|
||
object AppJumpTargetBlacklist : BlackListBean( | ||
PrefsData( | ||
"app_jump_target_blacklist", | ||
setOf("com.android.camera", "com.miui.tsmclient", "com.lbe.security.miui") | ||
) | ||
) | ||
|
||
object AppShareSourceBlacklist : | ||
BlackListBean(PrefsData("app_share_source_blacklist", setOf("com.android.providers.media.module"))) | ||
|
||
object AppShareTargetBlacklist : BlackListBean( | ||
PrefsData( | ||
"app_share_target_blacklist", | ||
setOf("com.android.camera", "com.miui.tsmclient", "com.lbe.security.miui") | ||
) | ||
) | ||
|
||
object ParallelFreeformBlacklist : BlackListBean( | ||
PrefsData( | ||
"parallel_small_window_blacklist", | ||
setOf("com.android.camera", "com.miui.tsmclient", "com.lbe.security.miui") | ||
) | ||
) | ||
|
||
object TileBlacklist : BlackListBean( | ||
PrefsData( | ||
"tile_blacklist", | ||
setOf("com.android.camera", "com.miui.tsmclient", "com.lbe.security.miui") | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
app/src/main/java/org/liuyi/mifreeformx/activity/page/AppSelectPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.liuyi.mifreeformx.activity.page | ||
|
||
import android.annotation.SuppressLint | ||
import cn.fkj233.ui.activity.annotation.BMPage | ||
import cn.fkj233.ui.activity.fragment.MIUIFragment | ||
import com.blankj.utilcode.util.AppUtils | ||
import com.highcapable.yukihookapi.hook.factory.prefs | ||
import com.highcapable.yukihookapi.hook.log.loggerD | ||
import org.liuyi.mifreeformx.R | ||
import org.liuyi.mifreeformx.adapter.AppSelectAdapter | ||
import org.liuyi.mifreeformx.bean.BlackListBean | ||
import org.liuyi.mifreeformx.utils.PinyinUtils | ||
import kotlin.concurrent.thread | ||
|
||
/** | ||
* @Author: Liuyi | ||
* @Date: 2023/05/07/13:26:35 | ||
* @Description: | ||
*/ | ||
@SuppressLint("NonConstantResourceId") | ||
@BMPage(key = "AppSelectPage", titleId = R.string.select_app) | ||
class AppSelectPage : MyBasePage() { | ||
|
||
init { | ||
skipLoadItem = true | ||
} | ||
|
||
companion object { | ||
init { | ||
thread { allAppInfo } | ||
} | ||
|
||
val allAppInfo: MutableList<AppUtils.AppInfo> by lazy { AppUtils.getAppsInfo() } | ||
var currentBlackList: BlackListBean? = null | ||
} | ||
|
||
private var lastBlackList: BlackListBean? = null | ||
|
||
|
||
private val mAppSelectAdapter by lazy { | ||
AppSelectAdapter(activity, allAppInfo.toMutableList(), mutableSetOf(), setOf()) { _, _ -> | ||
lastBlackList?.addAll(activity.prefs(), selectedSet) | ||
} | ||
} | ||
|
||
|
||
override fun onCreate() { | ||
List { | ||
adapter = mAppSelectAdapter | ||
} | ||
} | ||
|
||
override fun asyncInit(fragment: MIUIFragment) { | ||
fragment.showLoading() | ||
// 初始化 | ||
mAppSelectAdapter.apply { | ||
val current = currentBlackList?.getAll(activity.prefs()) | ||
|
||
mAppInfoList = current?.let { | ||
allAppInfo.toMutableList().apply { | ||
sortWith { a1, a2 -> | ||
if (current.contains(a1.packageName) && current.contains(a2.packageName)) { | ||
PinyinUtils.ccs2Pinyin(a1.name).compareTo(PinyinUtils.ccs2Pinyin(a2.name)) | ||
} else if (current.contains(a1.packageName)) { | ||
-1 | ||
} else if (current.contains(a2.packageName)) { | ||
1 | ||
} else PinyinUtils.ccs2Pinyin(a1.name).compareTo(PinyinUtils.ccs2Pinyin(a2.name)) | ||
} | ||
} | ||
} ?: mutableListOf() | ||
|
||
disEnabledSet = currentBlackList?.forceList ?: setOf() | ||
selectedSet = current?.toMutableSet() ?: mutableSetOf() | ||
|
||
loggerD(msg = "当前黑名单: $currentBlackList") | ||
loggerD(msg = "上次黑名单: $lastBlackList") | ||
loggerD(msg = "不可选项: $disEnabledSet") | ||
loggerD(msg = "当前选择项: $selectedSet") | ||
notifyDataSetChanged() | ||
} | ||
lastBlackList = currentBlackList | ||
currentBlackList = null | ||
fragment.initData() | ||
fragment.closeLoading() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/org/liuyi/mifreeformx/adapter/AppSelectAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.liuyi.mifreeformx.adapter | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.BaseAdapter | ||
import android.widget.CompoundButton | ||
import android.widget.LinearLayout | ||
import cn.fkj233.ui.activity.fragment.MIUIFragment | ||
import cn.fkj233.ui.activity.view.ImageTextSummaryWithSwitchV | ||
import cn.fkj233.ui.activity.view.ImageV | ||
import cn.fkj233.ui.activity.view.SwitchV | ||
import cn.fkj233.ui.activity.view.TextSummaryV | ||
import com.blankj.utilcode.util.AppUtils.AppInfo | ||
|
||
/** | ||
* @Author: Liuyi | ||
* @Date: 2023/05/08/22:21:49 | ||
* @Description: | ||
*/ | ||
class AppSelectAdapter( | ||
var mContext: Context, | ||
var mAppInfoList: MutableList<AppInfo>, | ||
var selectedSet: MutableSet<String>, | ||
var disEnabledSet: Set<String>, | ||
private val block: AppSelectAdapter.(Boolean, AppInfo) -> Unit | ||
) : BaseAdapter() { | ||
|
||
|
||
override fun getCount() = mAppInfoList.size | ||
|
||
override fun getItem(position: Int) = mAppInfoList[position] | ||
|
||
override fun getItemId(position: Int) = position.toLong() | ||
|
||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View { | ||
return LinearLayout(mContext).also { layout -> | ||
mAppInfoList[position].run { | ||
SwitchV("").let { switchV -> | ||
ImageTextSummaryWithSwitchV( | ||
ImageV(icon), | ||
TextSummaryV(text = name, tips = packageName), | ||
switchV | ||
).let { | ||
it.onDraw(MIUIFragment(""), layout, it.create(mContext) {}) | ||
switchV.switch.apply { | ||
isChecked = selectedSet.contains(packageName) | ||
isEnabled = !disEnabledSet.contains(packageName) | ||
setOnCheckedChangeListener { _, isChecked -> | ||
if (isChecked) selectedSet += this@run.packageName | ||
else selectedSet -= this@run.packageName | ||
block(this@AppSelectAdapter, isChecked, this@run) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.liuyi.mifreeformx.bean | ||
|
||
import android.app.Activity | ||
import com.highcapable.yukihookapi.hook.param.PackageParam | ||
import com.highcapable.yukihookapi.hook.xposed.prefs.YukiHookPrefsBridge | ||
|
||
/** | ||
* @Author: Liuyi | ||
* @Date: 2023/05/12/20:32:26 | ||
* @Description: | ||
*/ | ||
interface BlackList { | ||
|
||
fun add(prefs: YukiHookPrefsBridge? = null, item: String) | ||
|
||
fun addAll(prefs: YukiHookPrefsBridge? = null, items: Set<String>) | ||
|
||
fun remove(prefs: YukiHookPrefsBridge? = null, item: String) | ||
|
||
fun contains(prefs: YukiHookPrefsBridge? = null, item: String): Boolean | ||
|
||
fun size(prefs: YukiHookPrefsBridge? = null, item: String): Int | ||
|
||
fun clear(prefs: YukiHookPrefsBridge? = null, item: String) | ||
|
||
fun getAll(prefs: YukiHookPrefsBridge? = null): Set<String> | ||
} |
Oops, something went wrong.