Skip to content

Commit

Permalink
解除常用语剪贴板条数和时间限制功能同步上游
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Dec 23, 2023
1 parent c79fe6f commit 0c75467
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 139 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Android 11 ~ 14 的 MIUI 12.5 ~ 14/Xiaomi HyperOS1.0
- [「CorePatch」 by LSPosed](https://github.com/LSPosed/CorePatch)
- [「CustoMIUIzer」 by MonwF](https://github.com/MonwF/customiuizer)
- [「CustoMIUIzerMod」 by liyafe1997](https://github.com/liyafe1997/CustoMIUIzerMod)
- [「ClipboardList」 by 焕晨HChen](https://github.com/HChenX/ClipboardList)
- [「DexKit」 by LuckyPray](https://github.com/LuckyPray/DexKit)
- [「Disable app link verify」 by tehcneko](https://github.com/Xposed-Modules-Repo/io.github.tehcneko.applinkverify)
- [「DisableFlagSecure」 by LSPosed](https://github.com/LSPosed/DisableFlagSecure)
Expand Down
1 change: 1 addition & 0 deletions README_en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ You can provide translations for the HyperCeiler project [here](https://crwd.in/
- [「CorePatch」 by LSPosed](https://github.com/LSPosed/CorePatch)
- [「CustoMIUIzer」 by MonwF](https://github.com/MonwF/customiuizer)
- [「CustoMIUIzerMod」 by liyafe1997](https://github.com/liyafe1997/CustoMIUIzerMod)
- [「ClipboardList」 by 焕晨HChen](https://github.com/HChenX/ClipboardList)
- [「DexKit」 by LuckyPray](https://github.com/LuckyPray/DexKit)
- [「Disable app link verify」 by tehcneko](https://github.com/Xposed-Modules-Repo/io.github.tehcneko.applinkverify)
- [「DisableFlagSecure」 by LSPosed](https://github.com/LSPosed/DisableFlagSecure)
Expand Down
1 change: 1 addition & 0 deletions README_pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Você pode fornecer traduções para o projeto [aqui](https://crwd.in/cemiuiler)
- [「CorePatch」 por LSPosed](https://github.com/LSPosed/CorePatch)
- [「CustoMIUIzer」 por MonwF](https://github.com/MonwF/customiuizer)
- [「CustoMIUIzerMod」 por liyafe1997](https://github.com/liyafe1997/CustoMIUIzerMod)
- [「ClipboardList」 by 焕晨HChen](https://github.com/HChenX/ClipboardList)
- [「DexKit」 por LuckyPray](https://github.com/LuckyPray/DexKit)
- [「Disable app link verify」 por tehcneko](https://github.com/Xposed-Modules-Repo/io.github.tehcneko.applinkverify)
- [「DisableFlagSecure」 por LSPosed](https://github.com/LSPosed/DisableFlagSecure)
Expand Down
48 changes: 46 additions & 2 deletions app/src/main/java/com/sevtinge/hyperceiler/module/app/Various.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
package com.sevtinge.hyperceiler.module.app;

import android.content.Context;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;

import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.hook.various.ClipboardList;
import com.sevtinge.hyperceiler.module.hook.various.CollapseMiuiTitle;
import com.sevtinge.hyperceiler.module.hook.various.DialogCustom;
import com.sevtinge.hyperceiler.module.hook.various.MiuiAppNoOverScroll;
import com.sevtinge.hyperceiler.module.hook.various.UnlockIme;
import com.sevtinge.hyperceiler.utils.XposedUtils;
import com.sevtinge.hyperceiler.utils.log.XposedLogUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

public class Various extends BaseModule {
Class<?> mHelpers;
String mPackageName;
boolean isMiuiApps;

public static List<String> mAppsUsingInputMethod = new ArrayList<>();

@Override
public void handleLoadPackage() {
if (mAppsUsingInputMethod.isEmpty()) {
mAppsUsingInputMethod = getAppsUsingInputMethod(XposedUtils.findContext());
}
mPackageName = mLoadPackageParam.packageName;
isMiuiApps = mPackageName.startsWith("com.miui") || mPackageName.startsWith("com.xiaomi") || miuiDialogCustomApps.contains(mPackageName);

Expand All @@ -25,14 +38,45 @@ public void handleLoadPackage() {

initHook(new CollapseMiuiTitle(), isCollapseMiuiTitleApps());

initHook(new UnlockIme(), mPrefsMap.getBoolean("various_unlock_ime"));
initHook(new UnlockIme(), mPrefsMap.getBoolean("various_unlock_ime") && isInputMethod(mPackageName));

initHook(new ClipboardList(), mPrefsMap.getBoolean("various_phrase_clipboardlist"));
initHook(new ClipboardList(), mPrefsMap.getBoolean("various_phrase_clipboardlist") && isInputMethod(mPackageName));

// initHook(new NoBrightness(), isPay(mPackageName));

}

private List<String> getAppsUsingInputMethod(Context context) {
try {
if (context == null) {
XposedLogUtils.logE("getAppsUsingInputMethod", "context is null");
return new ArrayList<>();
}
List<String> pkgName = new ArrayList<>();
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> enabledInputMethods = inputMethodManager.getEnabledInputMethodList();
for (InputMethodInfo inputMethodInfo : enabledInputMethods) {
pkgName.add(inputMethodInfo.getServiceInfo().packageName);
}
return pkgName;
} catch (Throwable e) {
XposedLogUtils.logE("getAppsUsingInputMethod", "have e: " + e);
return new ArrayList<>();
}
}

private boolean isInputMethod(String pkgName) {
if (mAppsUsingInputMethod.isEmpty()) {
return false;
}
for (String inputMethod : mAppsUsingInputMethod) {
if (inputMethod.equals(pkgName)) {
return true;
}
}
return false;
}

private boolean isPay(String param) {
return mPrefsMap.getBoolean("various_nobrightness") && checkPay(param);
}
Expand Down
Loading

0 comments on commit 0c75467

Please sign in to comment.