-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
does not use androidx.core:core-splashscreen but might be replaced in the future.
- Loading branch information
Showing
14 changed files
with
186 additions
and
58 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
app/src/main/kotlin/top/laoxin/modmanager/ui/state/ModUiState.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
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
2 changes: 1 addition & 1 deletion
2
...oxin/modmanager/ui/view/modview/AllMod.kt → ...oxin/modmanager/ui/view/modView/AllMod.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
2 changes: 1 addition & 1 deletion
2
.../laoxin/modmanager/ui/view/modview/Mod.kt → .../laoxin/modmanager/ui/view/modView/Mod.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
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
2 changes: 1 addition & 1 deletion
2
...n/modmanager/ui/view/modview/ModDetail.kt → ...n/modmanager/ui/view/modView/ModDetail.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
2 changes: 1 addition & 1 deletion
2
...xin/modmanager/ui/view/modview/ModList.kt → ...xin/modmanager/ui/view/modView/ModList.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package top.lings.start | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.asPaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.systemBars | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import kotlinx.coroutines.delay | ||
import top.laoxin.modmanager.R | ||
|
||
@Composable | ||
fun Start(onTimeout: () -> Unit) { | ||
val isTimedOut = rememberSaveable { mutableStateOf(false) } | ||
|
||
LaunchedEffect(Unit) { | ||
if (!isTimedOut.value) { | ||
delay(1000) | ||
isTimedOut.value = true | ||
onTimeout() | ||
} | ||
} | ||
|
||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.background) | ||
.padding(WindowInsets.systemBars.asPaddingValues()), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.app_icon), | ||
contentDescription = null, | ||
tint = Color.Unspecified, | ||
modifier = Modifier | ||
.size(128.dp) | ||
.clip(RoundedCornerShape(16.dp)) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun Pre() { | ||
MaterialTheme { | ||
Start(onTimeout = {}) | ||
} | ||
} |
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,92 @@ | ||
package top.lings.start | ||
|
||
import android.content.Intent | ||
import android.content.pm.ActivityInfo | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.util.DisplayMetrics | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.core.view.WindowCompat | ||
import androidx.core.view.WindowInsetsControllerCompat | ||
import top.laoxin.modmanager.MainActivity | ||
import top.lings.userAgreement.UserAgreementActivity | ||
|
||
class StartActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
// 设置全屏模式,使内容可以扩展到状态栏和导航栏区域 | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
// 通过背景色使状态栏和导航栏透明 | ||
window.setBackgroundDrawableResource(android.R.color.transparent) | ||
|
||
// 启用 Edge-to-Edge 模式 | ||
enableEdgeToEdge() | ||
|
||
// 检查屏幕方向 | ||
checkOrientation() | ||
|
||
setContent { | ||
// 设置导航栏背景颜色和图标亮度 | ||
WindowInsetsControllerCompat(window, window.decorView).apply { | ||
isAppearanceLightNavigationBars = true | ||
@Suppress("DEPRECATION") | ||
window.navigationBarColor = MaterialTheme.colorScheme.surfaceContainer.toArgb() | ||
} | ||
MaterialTheme( | ||
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme() | ||
) { | ||
Start(onTimeout = { | ||
// 检查用户协议状态并跳转到 MainActivity 或 UserAgreementActivity | ||
val sharedPreferences = getSharedPreferences("AppLaunch", MODE_PRIVATE) | ||
val isConfirm = sharedPreferences.getBoolean("isConfirm", false) | ||
|
||
val intent = if (isConfirm) { | ||
Intent(this, MainActivity::class.java) | ||
} else { | ||
Intent(this, UserAgreementActivity::class.java) | ||
} | ||
|
||
startActivity(intent) | ||
finish() | ||
}) | ||
} | ||
} | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
|
||
// 检查屏幕方向 | ||
fun checkOrientation() { | ||
// 获取屏幕宽度 | ||
val screenWidthDp = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
// Android 11 | ||
val windowMetrics = windowManager.currentWindowMetrics | ||
val widthPixels = windowMetrics.bounds.width() | ||
widthPixels / resources.displayMetrics.density | ||
} else { | ||
// Android 10 | ||
@Suppress("DEPRECATION") | ||
windowManager.defaultDisplay.getMetrics(DisplayMetrics()) | ||
DisplayMetrics().widthPixels / DisplayMetrics().density | ||
} | ||
|
||
// 根据屏幕宽度设置屏幕方向 | ||
requestedOrientation = if (screenWidthDp >= 600) { | ||
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | ||
} else { | ||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Theme.ModManager" parent="android:Theme.Material.Light.NoActionBar" /> | ||
<style name="Theme.ModManager" parent="android:Theme.Material.Light.NoActionBar"> | ||
<item name="android:windowDisablePreview">true</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
</style> | ||
|
||
</resources> |