diff --git a/app/src/main/java/org/xtimms/tokusho/MainActivity.kt b/app/src/main/java/org/xtimms/tokusho/MainActivity.kt index b0910d7..fa270cd 100644 --- a/app/src/main/java/org/xtimms/tokusho/MainActivity.kt +++ b/app/src/main/java/org/xtimms/tokusho/MainActivity.kt @@ -56,7 +56,8 @@ import javax.inject.Inject @AndroidEntryPoint class MainActivity : ComponentActivity() { - @Inject lateinit var coil: ImageLoader + @Inject + lateinit var coil: ImageLoader override fun onCreate(savedInstanceState: Bundle?) { enableEdgeToEdge() @@ -146,7 +147,7 @@ fun MainView( BottomNavBar( navController = navController, bottomBarState = bottomBarState, - topBarOffsetY = topBarOffsetY + topBarOffsetY = topBarOffsetY, ) } }, @@ -170,7 +171,6 @@ fun MainView( bottom = systemBarsPadding.calculateBottomPadding() ), topBarHeightPx = topBarHeightPx, - topBarOffsetY = topBarOffsetY, listState = scroll ) } @@ -188,7 +188,6 @@ fun MainView( ), padding = padding, topBarHeightPx = topBarHeightPx, - topBarOffsetY = topBarOffsetY, listState = scroll ) } diff --git a/app/src/main/java/org/xtimms/tokusho/core/Navigation.kt b/app/src/main/java/org/xtimms/tokusho/core/Navigation.kt index 4eb176d..17c9312 100644 --- a/app/src/main/java/org/xtimms/tokusho/core/Navigation.kt +++ b/app/src/main/java/org/xtimms/tokusho/core/Navigation.kt @@ -65,7 +65,6 @@ fun Navigation( modifier: Modifier, padding: PaddingValues, topBarHeightPx: Float, - topBarOffsetY: Animatable, listState: LazyGridState, ) { @@ -128,7 +127,6 @@ fun Navigation( }, padding = padding, topBarHeightPx = topBarHeightPx, - topBarOffsetY = topBarOffsetY, listState = listState ) } diff --git a/app/src/main/java/org/xtimms/tokusho/sections/explore/ExploreView.kt b/app/src/main/java/org/xtimms/tokusho/sections/explore/ExploreView.kt index f6c2bb9..4bc40b2 100644 --- a/app/src/main/java/org/xtimms/tokusho/sections/explore/ExploreView.kt +++ b/app/src/main/java/org/xtimms/tokusho/sections/explore/ExploreView.kt @@ -50,7 +50,6 @@ fun ExploreView( coil: ImageLoader, navigateToSource: (MangaSource) -> Unit, topBarHeightPx: Float, - topBarOffsetY: Animatable, listState: LazyGridState, padding: PaddingValues, ) { @@ -63,7 +62,6 @@ fun ExploreView( uiState = uiState, event = viewModel, topBarHeightPx = topBarHeightPx, - topBarOffsetY = topBarOffsetY, listState = listState, padding = padding ) @@ -108,12 +106,7 @@ fun ExploreViewContent( ) LazyVerticalGrid( columns = GridCells.Adaptive(minSize = 90.dp), - modifier = listModifier - .collapsable( - state = listState, - topBarHeightPx = topBarHeightPx, - topBarOffsetY = topBarOffsetY, - ), + modifier = listModifier, state = listState, contentPadding = PaddingValues( start = padding.calculateStartPadding(layoutDirection) + 8.dp, diff --git a/app/src/main/java/org/xtimms/tokusho/sections/settings/advanced/AdvancedView.kt b/app/src/main/java/org/xtimms/tokusho/sections/settings/advanced/AdvancedView.kt index ec8a4f0..9b1c58d 100644 --- a/app/src/main/java/org/xtimms/tokusho/sections/settings/advanced/AdvancedView.kt +++ b/app/src/main/java/org/xtimms/tokusho/sections/settings/advanced/AdvancedView.kt @@ -1,5 +1,6 @@ package org.xtimms.tokusho.sections.settings.advanced +import android.os.Build import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable @@ -16,6 +17,7 @@ import org.xtimms.tokusho.R import org.xtimms.tokusho.core.components.PreferenceItem import org.xtimms.tokusho.core.components.PreferenceSubtitle import org.xtimms.tokusho.core.components.ScaffoldWithTopAppBar +import org.xtimms.tokusho.utils.DeviceUtil import org.xtimms.tokusho.utils.WebViewUtil import org.xtimms.tokusho.utils.lang.toDateTimestampString import java.text.DateFormat @@ -62,6 +64,44 @@ fun AdvancedView( description = getWebViewVersion() ) } + item { + PreferenceSubtitle(text = stringResource(id = R.string.device_info)) + } + item { + PreferenceItem( + title = "Model", + description = "${Build.MANUFACTURER} ${Build.MODEL} (${Build.DEVICE})" + ) + } + if (DeviceUtil.oneUiVersion != null) { + item { + PreferenceItem( + title = "OneUI version", + description = "${DeviceUtil.oneUiVersion}" + ) + } + } + if (DeviceUtil.miuiMajorVersion != null) { + item { + PreferenceItem( + title = "MIUI version", + description = "${DeviceUtil.miuiMajorVersion}", + ) + } + } + val androidVersion = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Build.VERSION.RELEASE_OR_PREVIEW_DISPLAY + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + Build.VERSION.RELEASE_OR_CODENAME + } else { + Build.VERSION.RELEASE + } + item { + PreferenceItem( + title = "Android version", + description = "$androidVersion (${Build.DISPLAY})" + ) + } } } } diff --git a/app/src/main/java/org/xtimms/tokusho/utils/DeviceUtil.kt b/app/src/main/java/org/xtimms/tokusho/utils/DeviceUtil.kt new file mode 100644 index 0000000..9cb604a --- /dev/null +++ b/app/src/main/java/org/xtimms/tokusho/utils/DeviceUtil.kt @@ -0,0 +1,93 @@ +package org.xtimms.tokusho.utils + +import android.annotation.SuppressLint +import android.app.ActivityManager +import android.content.Context +import android.os.Build +import androidx.core.content.getSystemService + +object DeviceUtil { + + val isMiui: Boolean by lazy { + getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false + } + + /** + * Extracts the MIUI major version code from a string like "V12.5.3.0.QFGMIXM". + * + * @return MIUI major version code (e.g., 13) or null if can't be parsed. + */ + val miuiMajorVersion: Int? by lazy { + if (!isMiui) return@lazy null + + Build.VERSION.INCREMENTAL + .substringBefore('.') + .trimStart('V') + .toIntOrNull() + } + + @SuppressLint("PrivateApi") + fun isMiuiOptimizationDisabled(): Boolean { + val sysProp = getSystemProperty("persist.sys.miui_optimization") + if (sysProp == "0" || sysProp == "false") { + return true + } + + return try { + Class.forName("android.miui.AppOpsUtils") + .getDeclaredMethod("isXOptMode") + .invoke(null) as Boolean + } catch (e: Exception) { + false + } + } + + val isSamsung: Boolean by lazy { + Build.MANUFACTURER.equals("samsung", ignoreCase = true) + } + + val oneUiVersion: Double? by lazy { + try { + val semPlatformIntField = Build.VERSION::class.java.getDeclaredField("SEM_PLATFORM_INT") + val version = semPlatformIntField.getInt(null) - 90000 + if (version < 0) { + 1.0 + } else { + ((version / 10000).toString() + "." + version % 10000 / 100).toDouble() + } + } catch (e: Exception) { + null + } + } + + val invalidDefaultBrowsers = listOf( + "android", + "com.huawei.android.internal.app", + "com.zui.resolver", + ) + + /** + * ActivityManager#isLowRamDevice is based on a system property, which isn't + * necessarily trustworthy. 1GB is supposedly the regular threshold. + * + * Instead, we consider anything with less than 3GB of RAM as low memory + * considering how heavy image processing can be. + */ + fun isLowRamDevice(context: Context): Boolean { + val memInfo = ActivityManager.MemoryInfo() + context.getSystemService()!!.getMemoryInfo(memInfo) + val totalMemBytes = memInfo.totalMem + return totalMemBytes < 3L * 1024 * 1024 * 1024 + } + + @SuppressLint("PrivateApi") + private fun getSystemProperty(key: String?): String? { + return try { + Class.forName("android.os.SystemProperties") + .getDeclaredMethod("get", String::class.java) + .invoke(null, key) as String + } catch (e: Exception) { + null + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1ae4b4..20a9867 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -79,4 +79,5 @@ Build time WebView version Dump crash logs, debug info + Device info \ No newline at end of file