Skip to content

Commit a63d097

Browse files
committed
[2/2][fix]: lock screen blur button on hyperos 2.0.200+
1 parent 92b0a07 commit a63d097

3 files changed

Lines changed: 91 additions & 81 deletions

File tree

app/src/main/java/com/sevtinge/hyperceiler/model/adapter/DynamicFragmentPagerAdapter.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ public class DynamicFragmentPagerAdapter extends PagerAdapter {
4343
private static final String TAG = "HC:DynamicFragmentPagerAdapter";
4444

4545
private String mCurrTab;
46-
private int mFragmentSize;
46+
private final int mFragmentSize;
4747

48-
private AppCompatActivity mActivity;
48+
private final AppCompatActivity mActivity;
4949
private FragmentManager mFragmentManager;
5050
private Fragment mCurrentPrimaryItem = null;
5151
private FragmentTransaction mCurTransaction = null;
5252

5353
private final Map<String, FragmentInfo> mFragmentCache;
5454

55-
class FragmentInfo {
55+
static class FragmentInfo {
5656

5757
String tag;
5858
boolean lazyInit;
@@ -95,14 +95,14 @@ public Object instantiateItem(@NonNull ViewGroup container, int position) {
9595
mCurTransaction = mFragmentManager.beginTransaction();
9696
}
9797
Fragment fragment = getFragment(tag, true);
98-
if (fragment.getFragmentManager() != null) {
98+
if (fragment.getParentFragment() != null) {
9999
mCurTransaction.attach(fragment);
100100
} else {
101101
mCurTransaction.add(container.getId(), fragment, tag);
102102
}
103103
if (fragment != mCurrentPrimaryItem) {
104104
fragment.setMenuVisibility(false);
105-
fragment.setUserVisibleHint(false);
105+
// fragment.setUserVisibleHint(false);
106106
}
107107
return fragment;
108108
}
@@ -132,11 +132,11 @@ public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull
132132
if (fragment != mCurrentPrimaryItem) {
133133
if (mCurrentPrimaryItem != null) {
134134
mCurrentPrimaryItem.setMenuVisibility(false);
135-
mCurrentPrimaryItem.setUserVisibleHint(false);
135+
// mCurrentPrimaryItem.setUserVisibleHint(false);
136136
}
137137
if (fragment != null) {
138138
fragment.setMenuVisibility(true);
139-
fragment.setUserVisibleHint(true);
139+
// fragment.setUserVisibleHint(true);
140140
}
141141
mCurrentPrimaryItem = fragment;
142142
}
@@ -169,7 +169,8 @@ public Fragment getFragment(String tag, boolean z) {
169169
fragmentInfo.fragment = mFragmentManager.findFragmentByTag(fragmentInfo.tag);
170170
}
171171
if (z && fragmentInfo.fragment == null) {
172-
fragmentInfo.fragment = Fragment.instantiate(mActivity, fragmentInfo.clazz.getName());
172+
fragmentInfo.fragment = mFragmentManager.getFragmentFactory()
173+
.instantiate(mActivity.getClassLoader(), fragmentInfo.clazz.getName());
173174
}
174175
return fragmentInfo.fragment;
175176
}
@@ -180,7 +181,8 @@ public Fragment getFragment(String tag, boolean z) {
180181
case TabViewModel.TAB_SETTINGS -> name = SettingsPageFragment.class.getName();
181182
case TabViewModel.TAB_ABOUT -> name = AboutPageFragment.class.getName();
182183
}
183-
return Fragment.instantiate(mActivity, name);
184+
return mFragmentManager.getFragmentFactory()
185+
.instantiate(mActivity.getClassLoader(), name);
184186
}
185187
return mFragmentManager.findFragmentByTag(tag);
186188
}
@@ -202,6 +204,8 @@ public void reCreateFragment() {
202204
}
203205

204206
private Fragment getNewFragment(String str) {
205-
return Fragment.instantiate(mActivity, mFragmentCache.get(str).clazz.getName());
207+
ClassLoader classLoader = mActivity.getClassLoader();
208+
String className = mFragmentCache.get(str).clazz.getName();
209+
return mFragmentManager.getFragmentFactory().instantiate(classLoader, className);
206210
}
207211
}

library/common-ui/java/main/src/com/sevtinge/hyperceiler/common/utils/search/SearchHelper.java

Lines changed: 72 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,12 @@
9191
import java.util.HashSet;
9292
import java.util.List;
9393
import java.util.Set;
94-
import java.util.concurrent.Executors;
9594

9695
public class SearchHelper {
9796

9897
public static final int MARK_COLOR_VIBRANT = Color.rgb(255, 0, 0);
9998
public static final String NEW_MODS_SEARCH_QUERY = "\uD83C\uDD95";
100-
public static List<ModData> allModsList = new ArrayList<>();
99+
public static final List<ModData> allModsList = new ArrayList<>();
101100

102101
public static String TAG = "SearchHelper";
103102

@@ -360,100 +359,103 @@ private static void parsePrefXml(Context context, Class<?> catPrefsFragment, int
360359
parsePrefXml(context, catPrefsFragment.getName(), xmlResId, internalId);
361360
}
362361

363-
private static void parsePrefXml(Context context, String catPrefsFragment, int xmlResId, int... internalId) {
364-
Executors.newSingleThreadExecutor().execute(() -> {
365-
Resources res = context.getResources();
366-
try (XmlResourceParser xml = res.getXml(xmlResId)) {
367-
int order = 0;
368-
String location = null, locationHyper = null, locationPad = null;
369-
int locationId = 0, locationHyperId = 0, locationPadId = 0;
370-
boolean isPad = isPad();
371-
StringBuilder internalName = null;
372-
int eventType = xml.getEventType();
373-
374-
if (internalId.length != 0) {
375-
internalName = new StringBuilder();
376-
for (int id : internalId) {
377-
if (internalName.length() > 0) {
378-
internalName.append("/");
362+
private static void parsePrefXml(Context context, String catPrefsFragment, int xmlResId, int... internalId) {
363+
ThreadPoolManager.getInstance().submit(() -> {
364+
Resources res = context.getResources();
365+
try (XmlResourceParser xml = res.getXml(xmlResId)) {
366+
int order = 0;
367+
String location = null, locationPad = null;
368+
int locationId = 0, locationPadId = 0;
369+
boolean isPadDevice = isPad();
370+
StringBuilder internalName = null;
371+
int eventType = xml.getEventType();
372+
373+
if (internalId.length != 0) {
374+
internalName = new StringBuilder();
375+
for (int id : internalId) {
376+
if (internalName.length() > 0) {
377+
internalName.append("/");
378+
}
379+
380+
internalName.append(res.getString(id));
379381
}
380-
internalName.append(res.getString(id));
381382
}
382-
}
383383

384-
List<ModData> localList = new ArrayList<>();
384+
List<ModData> localList = new ArrayList<>(32);
385385

386-
while (eventType != XmlPullParser.END_DOCUMENT) {
387-
if (eventType == XmlPullParser.START_TAG && !xml.getName().equals("PreferenceCategory")) {
388-
try {
389-
ModData modData = new ModData();
390-
modData.title = getModTitle(res, xml.getAttributeValue(ANDROID_NS, "title"));
391-
boolean isPreferenceVisible = Boolean.parseBoolean(xml.getAttributeValue(APP_NS, "isPreferenceVisible"));
386+
while (eventType != XmlPullParser.END_DOCUMENT) {
387+
if (eventType == XmlPullParser.START_TAG && !"PreferenceCategory".equals(xml.getName())) {
388+
try {
389+
String titleAttr = xml.getAttributeValue(ANDROID_NS, "title");
390+
String keyAttr = xml.getAttributeValue(ANDROID_NS, "key");
391+
String isPrefVisibleAttr = xml.getAttributeValue(APP_NS, "isPreferenceVisible");
392+
String myLocationPadAttr = xml.getAttributeValue(APP_NS, "myLocationPad");
393+
String myLocationAttr = xml.getAttributeValue(APP_NS, "myLocation");
392394

393-
if (locationPad == null) {
394-
locationPad = getModTitle(res, xml.getAttributeValue(APP_NS, "myLocationPad"));
395-
locationPadId = getModId(xml.getAttributeValue(APP_NS, "myLocationPad"));
396-
}
397-
if (location == null) {
398-
location = getModTitle(res, xml.getAttributeValue(APP_NS, "myLocation"));
399-
locationId = getModId(xml.getAttributeValue(APP_NS, "myLocation"));
400-
}
395+
String modTitle = getModTitle(res, titleAttr);
396+
boolean isPreferenceVisible = Boolean.parseBoolean(isPrefVisibleAttr);
397+
398+
if (locationPad == null && myLocationPadAttr != null) {
399+
locationPad = getModTitle(res, myLocationPadAttr);
400+
locationPadId = getModId(myLocationPadAttr);
401+
}
402+
if (location == null && myLocationAttr != null) {
403+
location = getModTitle(res, myLocationAttr);
404+
locationId = getModId(myLocationAttr);
405+
}
401406

402-
if (!TextUtils.isEmpty(modData.title) && !isPreferenceVisible) {
403-
String internalPad = internalName == null ? locationPad : internalName + "/" + locationPad;
404-
String internal = internalName == null ? location : internalName + "/" + location;
407+
if (!TextUtils.isEmpty(modTitle) && !isPreferenceVisible) {
408+
String internalPad = internalName == null ? locationPad : internalName + "/" + locationPad;
409+
String internal = internalName == null ? location : internalName + "/" + location;
405410

406-
if (locationHyper == null || location == null || (isPad && locationPad == null)) {
407-
if (location != null) {
411+
ModData modData = new ModData();
412+
modData.title = modTitle;
413+
if (location != null && (!isPadDevice || locationPad == null)) {
408414
modData.breadcrumbs = internal;
409415
modData.catTitleResId = locationId;
410416
} else if (locationPad != null) {
411417
modData.breadcrumbs = internalPad;
412418
modData.catTitleResId = locationPadId;
413419
}
414-
} else {
415-
if (!isPad) {
416-
modData.breadcrumbs = internal;
417-
modData.catTitleResId = locationId;
418-
} else {
419-
modData.breadcrumbs = internalPad;
420-
modData.catTitleResId = locationPadId;
421-
}
420+
modData.xml = xmlResId;
421+
modData.key = keyAttr;
422+
modData.order = order;
423+
modData.fragment = catPrefsFragment;
424+
localList.add(modData);
422425
}
423-
424-
modData.xml = xmlResId;
425-
modData.key = xml.getAttributeValue(ANDROID_NS, "key");
426-
modData.order = order;
427-
modData.fragment = catPrefsFragment;
428-
localList.add(modData);
426+
order++;
427+
} catch (Throwable t) {
428+
AndroidLogUtils.logE(TAG, "Failed to get xml keyword object!", t);
429429
}
430-
order++;
431-
} catch (Throwable t) {
432-
AndroidLogUtils.logE(TAG, "Failed to get xml keyword object!", t);
433430
}
431+
eventType = xml.next();
434432
}
435-
eventType = xml.next();
436-
}
437433

438-
synchronized (allModsList) {
439-
allModsList.addAll(localList);
440-
}
434+
if (!localList.isEmpty()) {
435+
synchronized (allModsList) {
436+
allModsList.addAll(localList);
437+
}
438+
}
441439

442-
} catch (Throwable t) {
443-
AndroidLogUtils.logE(TAG, "Failed to access XML resource!", t);
444-
}
445-
});
446-
}
440+
} catch (Throwable t) {
441+
AndroidLogUtils.logE(TAG, "Failed to access XML resource!", t);
442+
}
443+
});
444+
}
447445

448446
private static int getModId(String title) {
449447
if (title == null) {
450448
return -1;
451449
}
452-
int titleResId = Integer.parseInt(title.substring(1));
453-
if (titleResId <= 0) {
450+
try {
451+
int titleResId = Integer.parseInt(title.substring(1));
452+
if (titleResId <= 0) {
453+
return -1;
454+
}
455+
return titleResId;
456+
} catch (NumberFormatException e) {
454457
return -1;
455458
}
456-
return titleResId;
457459
}
458460

459461
private static String getModTitle(Resources res, String title) {

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/hook/systemui/lockscreen/BlurButton.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ import com.sevtinge.hyperceiler.hook.module.hook.systemui.base.lockscreen.Keygua
3232
import com.sevtinge.hyperceiler.hook.utils.blur.BlurUtils.createBlurDrawable
3333
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.addMiBackgroundBlendColor
3434
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.clearMiBackgroundBlendColor
35+
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.setMiBackgroundBlurMode
3536
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.setMiBackgroundBlurRadius
3637
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.setMiViewBlurMode
38+
import com.sevtinge.hyperceiler.hook.utils.blur.MiBlurUtilsKt.setPassWindowBlurEnabled
3739
import com.sevtinge.hyperceiler.hook.utils.devicesdk.isHyperOSVersion
3840
import com.sevtinge.hyperceiler.hook.utils.getObjectFieldAs
3941
import com.sevtinge.hyperceiler.hook.utils.getObjectFieldOrNullAs
@@ -145,8 +147,10 @@ object BlurButton : BaseHook() {
145147
view.clipToOutline = true
146148
view.apply {
147149
clearMiBackgroundBlendColor()
150+
setPassWindowBlurEnabled(true)
148151
setMiViewBlurMode(1)
149-
setMiBackgroundBlurRadius(40)
152+
setMiBackgroundBlurMode(1)
153+
setMiBackgroundBlurRadius(100)
150154
addMiBackgroundBlendColor(mPrefsMap.getInt("system_ui_lock_screen_blur_button_bg_color", 0), 101)
151155
}
152156
}

0 commit comments

Comments
 (0)