Skip to content

Commit

Permalink
opt: add isLargeUI()
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Jan 13, 2025
1 parent c225eeb commit 377c428
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinde
import com.sevtinge.hyperceiler.module.base.*
import com.sevtinge.hyperceiler.module.hook.systemui.*
import com.sevtinge.hyperceiler.utils.*
import com.sevtinge.hyperceiler.utils.api.LazyClass.miuiConfigs
import com.sevtinge.hyperceiler.utils.devicesdk.*
import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.*
import com.sevtinge.hyperceiler.view.*
Expand Down Expand Up @@ -105,10 +106,10 @@ object NotificationWeather : BaseHook() {
val landClock = viewGroup.getObjectFieldAs<TextView>("mLandClock")

vWeatherView?.setTextSize(0, dateView.textSize)
vWeatherView?.setTypeface(dateView.typeface)
vWeatherView?.typeface = dateView.typeface

hWeatherView?.setTextSize(0, landClock.textSize)
hWeatherView?.setTypeface(landClock.typeface)
hWeatherView?.typeface = landClock.typeface
}
}

Expand All @@ -128,12 +129,9 @@ object NotificationWeather : BaseHook() {
}

val isVerticalMode = if (isMoreHyperOSVersion(2f)) {
val miuiConfigs = loadClass("com.miui.utils.configs.MiuiConfigs")
miuiConfigs.callStaticMethodAs<Boolean>("isVerticalMode", context)
miuiConfigs.callStaticMethodAs("isVerticalMode", context)
} else {
val commonUtil = loadClass("com.miui.systemui.util.CommonUtil")
val isTabletUI = commonUtil.callStaticMethodAs<Boolean>("isTabletUI", context)
orientation != ORIENTATION_PORTRAIT || isTabletUI
orientation != ORIENTATION_PORTRAIT || isLargeUI()
}

if (isVerticalMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinde
import com.sevtinge.hyperceiler.module.base.*
import com.sevtinge.hyperceiler.module.base.MusicBaseHook.Companion.CHANNEL_ID
import com.sevtinge.hyperceiler.utils.*
import com.sevtinge.hyperceiler.utils.api.LazyClass.miuiConfigs
import de.robv.android.xposed.*
import kotlinx.coroutines.flow.*

Expand Down Expand Up @@ -138,7 +139,7 @@ object HideFakeStatusBar : MusicBaseHook() {
loadClass("com.android.systemui.controlcenter.shade.NotificationHeaderExpandController\$notificationCallback\$1").methodFinder()
.filterByName("onExpansionChanged").first().createHook {
before {
unhook0 = loadClass("com.miui.utils.configs.MiuiConfigs").methodFinder()
unhook0 = miuiConfigs.methodFinder()
.filterByName("isVerticalMode").first().replaceMethod {
if (isShowingFocusedLyric) {
// 如果在显示歌词,就伪装成横屏,用来取消假时钟动画
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ object LazyClass {
loadClass("miui.os.Build")
}

val miuiConfigs by lazy {
loadClass("miui.util.MiuiConfigs")
}

val SettingsFeaturesCls by lazy {
loadClass("com.android.settings.utils.SettingsFeatures")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,44 @@
*/
package com.sevtinge.hyperceiler.utils.devicesdk

import android.content.res.*
import com.github.kyuubiran.ezxhelper.ClassUtils.getStaticObjectOrNullAs
import com.sevtinge.hyperceiler.utils.api.LazyClass.clazzMiuiBuild

val IS_TABLET by lazy {
getStaticObjectOrNullAs<Boolean>(clazzMiuiBuild, "IS_TABLET") ?: false
}
val IS_PAD by lazy {
getStaticObjectOrNullAs<Boolean>(clazzMiuiBuild, "IS_PAD") ?: false
}
val IS_FOLD by lazy {
getStaticObjectOrNullAs<Boolean>(clazzMiuiBuild, "IS_FOLD") ?: false
}
val IS_INTERNATIONAL_BUILD by lazy {
getStaticObjectOrNullAs<Boolean>(clazzMiuiBuild, "IS_INTERNATIONAL_BUILD") ?: false
}

/**
* 函数调用,适用于其他一些需要更高精度判断大屏设备的情况,仅支持小米设备的判断
* @return 一个 Boolean 值,true 代表是大屏设备,false 代表不是大屏设备
*/
fun isLargeUI(): Boolean {
return runCatching {
!(!IS_PAD && (!IS_FOLD || !isTablet()))
}.getOrElse {
isPad()
}
}

/**
* 函数调用,适用于其他一些需要判断的情况,仅支持小米设备的判断
* 2025-04-20 更新对非小米设备的判断方式,仅防止闪退
* @return 一个 Boolean 值,true 代表是平板,false 代表不是平板
*/
fun isPad(): Boolean {
return try {
return runCatching {
IS_TABLET
} catch(_: Throwable) {
}.getOrElse {
isPadDevice()
}
}
Expand All @@ -46,9 +65,9 @@ fun isPad(): Boolean {
* @return 一个 Boolean 值,true 代表是国际版系统,false 代表不是国际版系统
*/
fun isInternational(): Boolean {
return try {
return runCatching {
IS_INTERNATIONAL_BUILD
} catch(_: Throwable) {
}.getOrElse {
false
}
}

0 comments on commit 377c428

Please sign in to comment.