├── .gitignore ├── .idea ├── AndroidProjectSystem.xml ├── compiler.xml ├── deploymentTargetSelector.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── migrations.xml ├── misc.xml ├── runConfigurations.xml ├── shelf │ ├── Uncommitted_changes_before_Update_at_2025_6_13_17_03_[Changes] │ │ └── shelved.patch │ ├── Uncommitted_changes_before_Update_at_2025_6_13_17_03__Changes_.xml │ ├── Uncommitted_changes_before_Update_at_2025_7_10_11_56_[Changes] │ │ └── shelved.patch │ ├── Uncommitted_changes_before_Update_at_2025_7_10_11_56__Changes_.xml │ ├── Uncommitted_changes_before_Update_at_2025_7_4_18_05_[Changes] │ │ └── shelved.patch │ ├── Uncommitted_changes_before_Update_at_2025_7_4_18_05_[Changes]1 │ │ └── shelved.patch │ └── Uncommitted_changes_before_Update_at_2025_7_4_18_05__Changes_.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── me │ │ └── neko │ │ └── nzhelper │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ │ └── me │ │ │ └── neko │ │ │ └── nzhelper │ │ │ ├── MainActivity.kt │ │ │ ├── NzApplication.kt │ │ │ ├── data │ │ │ └── SessionRepository.kt │ │ │ └── ui │ │ │ ├── screens │ │ │ ├── AboutScreen.kt │ │ │ ├── HistoryScreen.kt │ │ │ ├── HomeScreen.kt │ │ │ ├── MainScreen.kt │ │ │ ├── OpenSource.kt │ │ │ └── SettingsScreen.kt │ │ │ ├── service │ │ │ └── TimerService.kt │ │ │ ├── theme │ │ │ ├── Color.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ │ │ └── util │ │ │ ├── BottomNavItem.kt │ │ │ ├── CalendarHeatMap.kt │ │ │ ├── GitHubRelease.kt │ │ │ └── NotificationUtil.kt │ └── res │ │ ├── drawable │ │ ├── baseline_access_alarm_24.xml │ │ ├── code_24px.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_launcher_foreground.xml │ │ └── source_code_24px.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── me │ └── neko │ └── nzhelper │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | /build/ 17 | **/build/ 18 | **/release/ 19 | **/outputs/ 20 | *.apk 21 | *.aab -------------------------------------------------------------------------------- /.idea/AndroidProjectSystem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetSelector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 61 | -------------------------------------------------------------------------------- /.idea/migrations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_6_13_17_03_[Changes]/shelved.patch: -------------------------------------------------------------------------------- 1 | Index: app/release/output-metadata.json 2 | IDEA additional info: 3 | Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP 4 | <+>{\r\n \"version\": 3,\r\n \"artifactType\": {\r\n \"type\": \"APK\",\r\n \"kind\": \"Directory\"\r\n },\r\n \"applicationId\": \"me.neko.nzhelper\",\r\n \"variantName\": \"release\",\r\n \"elements\": [\r\n {\r\n \"type\": \"SINGLE\",\r\n \"filters\": [],\r\n \"attributes\": [],\r\n \"versionCode\": 14,\r\n \"versionName\": \"0.0.5-alpha.r14.e2fb6ce\",\r\n \"outputFile\": \"NzHelper_v0.0.5-alpha.r14.e2fb6ce.apk\"\r\n }\r\n ],\r\n \"elementType\": \"File\",\r\n \"baselineProfiles\": [\r\n {\r\n \"minApi\": 28,\r\n \"maxApi\": 30,\r\n \"baselineProfiles\": [\r\n \"baselineProfiles/1/NzHelper_v0.0.5-alpha.r14.e2fb6ce.dm\"\r\n ]\r\n },\r\n {\r\n \"minApi\": 31,\r\n \"maxApi\": 2147483647,\r\n \"baselineProfiles\": [\r\n \"baselineProfiles/0/NzHelper_v0.0.5-alpha.r14.e2fb6ce.dm\"\r\n ]\r\n }\r\n ],\r\n \"minSdkVersionForDexing\": 26\r\n} 5 | Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP 6 | <+>UTF-8 7 | =================================================================== 8 | diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json 9 | --- a/app/release/output-metadata.json (revision ac7cb9496579921dae020d1ec52d81a989328737) 10 | +++ b/app/release/output-metadata.json (date 1749805328589) 11 | @@ -11,9 +11,9 @@ 12 | "type": "SINGLE", 13 | "filters": [], 14 | "attributes": [], 15 | - "versionCode": 14, 16 | - "versionName": "0.0.5-alpha.r14.e2fb6ce", 17 | - "outputFile": "NzHelper_v0.0.5-alpha.r14.e2fb6ce.apk" 18 | + "versionCode": 4, 19 | + "versionName": "0.0.4-alpha", 20 | + "outputFile": "app-release.apk" 21 | } 22 | ], 23 | "elementType": "File", 24 | @@ -22,14 +22,14 @@ 25 | "minApi": 28, 26 | "maxApi": 30, 27 | "baselineProfiles": [ 28 | - "baselineProfiles/1/NzHelper_v0.0.5-alpha.r14.e2fb6ce.dm" 29 | + "baselineProfiles/1/app-release.dm" 30 | ] 31 | }, 32 | { 33 | "minApi": 31, 34 | "maxApi": 2147483647, 35 | "baselineProfiles": [ 36 | - "baselineProfiles/0/NzHelper_v0.0.5-alpha.r14.e2fb6ce.dm" 37 | + "baselineProfiles/0/app-release.dm" 38 | ] 39 | } 40 | ], 41 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_6_13_17_03__Changes_.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_10_11_56_[Changes]/shelved.patch: -------------------------------------------------------------------------------- 1 | Index: app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt 2 | IDEA additional info: 3 | Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP 4 | <+>package me.neko.nzhelper.ui.screens\r\n\r\nimport android.content.Context\r\nimport androidx.compose.foundation.layout.padding\r\nimport androidx.compose.material3.*\r\nimport androidx.compose.runtime.Composable\r\nimport androidx.compose.runtime.getValue\r\nimport androidx.compose.ui.Modifier\r\nimport androidx.compose.ui.platform.LocalContext\r\nimport androidx.compose.ui.tooling.preview.Preview\r\nimport androidx.navigation.NavController\r\nimport androidx.navigation.NavGraph.Companion.findStartDestination\r\nimport androidx.navigation.compose.*\r\nimport android.content.Intent\r\nimport android.provider.Settings\r\nimport androidx.compose.foundation.layout.WindowInsets\r\nimport androidx.compose.runtime.*\r\nimport androidx.compose.runtime.setValue\r\nimport androidx.core.app.NotificationManagerCompat\r\nimport androidx.navigation.compose.rememberNavController\r\nimport me.neko.nzhelper.BuildConfig\r\nimport androidx.core.net.toUri\r\nimport me.neko.nzhelper.ui.util.BottomNavItem\r\nimport me.neko.nzhelper.ui.util.UpdateChecker\r\n\r\n@Composable\r\nfun BottomNavigationBar(navController: NavController) {\r\n val navBackStackEntry by navController.currentBackStackEntryAsState()\r\n val currentRoute = navBackStackEntry?.destination?.route\r\n NavigationBar {\r\n BottomNavItem.Companion.items.forEach { item ->\r\n NavigationBarItem(\r\n icon = { Icon(imageVector = item.icon, contentDescription = item.title) },\r\n label = { Text(text = item.title) },\r\n selected = currentRoute == item.route,\r\n onClick = {\r\n navController.navigate(item.route) {\r\n launchSingleTop = true\r\n restoreState = true\r\n popUpTo(navController.graph.findStartDestination().id) {\r\n saveState = true\r\n }\r\n }\r\n }\r\n )\r\n }\r\n }\r\n}\r\n\r\n@OptIn(ExperimentalMaterial3Api::class)\r\n@Composable\r\nfun MainScreen() {\r\n val navController = rememberNavController()\r\n val context = LocalContext.current\r\n\r\n // 检查通知权限\r\n val notificationsEnabled = NotificationManagerCompat.from(context).areNotificationsEnabled()\r\n var showNotifyDialog by remember { mutableStateOf(!notificationsEnabled) }\r\n\r\n // 打开应用通知设置\r\n fun openNotificationSettings(context: Context) {\r\n val intent = Intent().apply {\r\n action =\r\n Settings.ACTION_APP_NOTIFICATION_SETTINGS\r\n putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName)\r\n putExtra(\"app_uid\", context.applicationInfo.uid)\r\n addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)\r\n }\r\n context.startActivity(intent)\r\n }\r\n\r\n val owner = \"bug-bit\"\r\n val repo = \"NzHelper\"\r\n\r\n var showUpdateDialog by remember { mutableStateOf(false) }\r\n var latestTag by remember { mutableStateOf(null) }\r\n\r\n fun stripSuffix(version: String): String =\r\n version.trimStart('v','V').substringBefore('-')\r\n\r\n fun parseNumbers(version: String): List =\r\n stripSuffix(version)\r\n .split('.')\r\n .map { it.toIntOrNull() ?: 0 }\r\n .let {\r\n when {\r\n it.size >= 3 -> it.take(3)\r\n it.size == 2 -> it + listOf(0)\r\n it.size == 1 -> it + listOf(0, 0)\r\n else -> listOf(0, 0, 0)\r\n }\r\n }\r\n\r\n fun isRemoteGreater(local: String, remote: String): Boolean {\r\n val localNums = parseNumbers(local)\r\n val remoteNums = parseNumbers(remote)\r\n for (i in 0..2) {\r\n if (remoteNums[i] > localNums[i]) return true\r\n if (remoteNums[i] < localNums[i]) return false\r\n }\r\n return false\r\n }\r\n\r\n LaunchedEffect(Unit) {\r\n UpdateChecker.fetchLatestVersion(owner, repo)?.let { remoteVer ->\r\n latestTag = remoteVer\r\n if (isRemoteGreater(BuildConfig.VERSION_NAME, remoteVer)) {\r\n showUpdateDialog = true\r\n }\r\n }\r\n }\r\n\r\n Scaffold(\r\n bottomBar = { BottomNavigationBar(navController) },\r\n contentWindowInsets = WindowInsets(0, 0, 0, 0)\r\n ) { innerPadding ->\r\n NavHost(\r\n navController = navController,\r\n startDestination = BottomNavItem.Home.route,\r\n modifier = Modifier.padding(innerPadding)\r\n ) {\r\n composable(BottomNavItem.Home.route) { HomeScreen() }\r\n composable(BottomNavItem.History.route) { HistoryScreen() }\r\n composable(BottomNavItem.Settings.route) { SettingsScreen() }\r\n }\r\n\r\n if (showUpdateDialog && latestTag != null) {\r\n AlertDialog(\r\n onDismissRequest = { showUpdateDialog = false },\r\n title = { Text(\"检测到新版本\") },\r\n text = {\r\n Text(\r\n \"当前版本:${BuildConfig.VERSION_NAME}\\n\" +\r\n \"最新版本:$latestTag\\n\\n\" +\r\n \"针对你的牛牛进行了一些优化,是否前往 GitHub 下载?\"\r\n )\r\n },\r\n confirmButton = {\r\n TextButton(onClick = {\r\n showUpdateDialog = false\r\n val intent = Intent(\r\n Intent.ACTION_VIEW,\r\n \"https://github.com/$owner/$repo/releases/latest\".toUri()\r\n )\r\n context.startActivity(intent)\r\n }) { Text(\"去下载\") }\r\n },\r\n dismissButton = {\r\n TextButton(onClick = { showUpdateDialog = false }) {\r\n Text(\"稍后再说\")\r\n }\r\n }\r\n )\r\n }\r\n if (showNotifyDialog) {\r\n AlertDialog(\r\n onDismissRequest = { showNotifyDialog = false },\r\n title = {\r\n Text(text = \"还未开启通知权限\")\r\n },\r\n text = {\r\n Text(\"为确保应用能在后台继续计时,请授予通知权限!\")\r\n },\r\n confirmButton = {\r\n Button(\r\n onClick = {\r\n openNotificationSettings(context)\r\n showNotifyDialog = false\r\n },\r\n colors = ButtonDefaults.buttonColors(\r\n containerColor = MaterialTheme.colorScheme.primary\r\n )\r\n ) {\r\n Text(\"去开启\")\r\n }\r\n },\r\n dismissButton = {\r\n TextButton(onClick = { showNotifyDialog = false }) {\r\n Text(\"以后再说\")\r\n }\r\n }\r\n )\r\n }\r\n }\r\n}\r\n\r\n@OptIn(ExperimentalMaterial3Api::class)\r\n@Preview(showBackground = true)\r\n@Composable\r\nfun MainScreenPreview() {\r\n MainScreen()\r\n}\r\n 5 | Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP 6 | <+>UTF-8 7 | =================================================================== 8 | diff --git a/app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt b/app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt 9 | --- a/app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt (revision 53dbb1212b49f88df6f6d0cd68e480b80ae8ac3e) 10 | +++ b/app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt (date 1752070251328) 11 | @@ -1,25 +1,39 @@ 12 | package me.neko.nzhelper.ui.screens 13 | 14 | import android.content.Context 15 | +import android.content.Intent 16 | +import android.provider.Settings 17 | +import androidx.compose.foundation.layout.WindowInsets 18 | import androidx.compose.foundation.layout.padding 19 | -import androidx.compose.material3.* 20 | +import androidx.compose.material3.AlertDialog 21 | +import androidx.compose.material3.Button 22 | +import androidx.compose.material3.ButtonDefaults 23 | +import androidx.compose.material3.ExperimentalMaterial3Api 24 | +import androidx.compose.material3.Icon 25 | +import androidx.compose.material3.MaterialTheme 26 | +import androidx.compose.material3.NavigationBar 27 | +import androidx.compose.material3.NavigationBarItem 28 | +import androidx.compose.material3.Scaffold 29 | +import androidx.compose.material3.Text 30 | +import androidx.compose.material3.TextButton 31 | import androidx.compose.runtime.Composable 32 | +import androidx.compose.runtime.LaunchedEffect 33 | import androidx.compose.runtime.getValue 34 | +import androidx.compose.runtime.mutableStateOf 35 | +import androidx.compose.runtime.remember 36 | +import androidx.compose.runtime.setValue 37 | import androidx.compose.ui.Modifier 38 | import androidx.compose.ui.platform.LocalContext 39 | import androidx.compose.ui.tooling.preview.Preview 40 | +import androidx.core.app.NotificationManagerCompat 41 | +import androidx.core.net.toUri 42 | import androidx.navigation.NavController 43 | import androidx.navigation.NavGraph.Companion.findStartDestination 44 | -import androidx.navigation.compose.* 45 | -import android.content.Intent 46 | -import android.provider.Settings 47 | -import androidx.compose.foundation.layout.WindowInsets 48 | -import androidx.compose.runtime.* 49 | -import androidx.compose.runtime.setValue 50 | -import androidx.core.app.NotificationManagerCompat 51 | +import androidx.navigation.compose.NavHost 52 | +import androidx.navigation.compose.composable 53 | +import androidx.navigation.compose.currentBackStackEntryAsState 54 | import androidx.navigation.compose.rememberNavController 55 | import me.neko.nzhelper.BuildConfig 56 | -import androidx.core.net.toUri 57 | import me.neko.nzhelper.ui.util.BottomNavItem 58 | import me.neko.nzhelper.ui.util.UpdateChecker 59 | 60 | @@ -70,13 +84,13 @@ 61 | } 62 | 63 | val owner = "bug-bit" 64 | - val repo = "NzHelper" 65 | + val repo = "NzHelper" 66 | 67 | var showUpdateDialog by remember { mutableStateOf(false) } 68 | var latestTag by remember { mutableStateOf(null) } 69 | 70 | fun stripSuffix(version: String): String = 71 | - version.trimStart('v','V').substringBefore('-') 72 | + version.trimStart('v', 'V').substringBefore('-') 73 | 74 | fun parseNumbers(version: String): List = 75 | stripSuffix(version) 76 | @@ -92,7 +106,7 @@ 77 | } 78 | 79 | fun isRemoteGreater(local: String, remote: String): Boolean { 80 | - val localNums = parseNumbers(local) 81 | + val localNums = parseNumbers(local) 82 | val remoteNums = parseNumbers(remote) 83 | for (i in 0..2) { 84 | if (remoteNums[i] > localNums[i]) return true 85 | @@ -121,7 +135,10 @@ 86 | ) { 87 | composable(BottomNavItem.Home.route) { HomeScreen() } 88 | composable(BottomNavItem.History.route) { HistoryScreen() } 89 | - composable(BottomNavItem.Settings.route) { SettingsScreen() } 90 | + composable(BottomNavItem.Settings.route) { SettingsScreen(navController) } 91 | + composable("about") { 92 | + AboutScreen(navController) 93 | + } 94 | } 95 | 96 | if (showUpdateDialog && latestTag != null) { 97 | Index: app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt 98 | IDEA additional info: 99 | Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP 100 | <+>package me.neko.nzhelper.ui.screens\r\n\r\nimport androidx.compose.foundation.clickable\r\nimport androidx.compose.foundation.layout.Column\r\nimport androidx.compose.foundation.layout.Spacer\r\nimport androidx.compose.foundation.layout.WindowInsets\r\nimport androidx.compose.foundation.layout.WindowInsetsSides\r\nimport androidx.compose.foundation.layout.fillMaxSize\r\nimport androidx.compose.foundation.layout.fillMaxWidth\r\nimport androidx.compose.foundation.layout.only\r\nimport androidx.compose.foundation.layout.padding\r\nimport androidx.compose.foundation.layout.safeDrawing\r\nimport androidx.compose.material.icons.Icons\r\nimport androidx.compose.material.icons.filled.Info\r\nimport androidx.compose.material3.ExperimentalMaterial3Api\r\nimport androidx.compose.material3.Icon\r\nimport androidx.compose.material3.ListItem\r\nimport androidx.compose.material3.MaterialTheme\r\nimport androidx.compose.material3.Scaffold\r\nimport androidx.compose.material3.Text\r\nimport androidx.compose.material3.TopAppBar\r\nimport androidx.compose.material3.TopAppBarDefaults\r\nimport androidx.compose.material3.rememberTopAppBarState\r\nimport androidx.compose.runtime.Composable\r\nimport androidx.compose.runtime.getValue\r\nimport androidx.compose.runtime.mutableStateOf\r\nimport androidx.compose.runtime.remember\r\nimport androidx.compose.runtime.setValue\r\nimport androidx.compose.ui.Modifier\r\nimport androidx.compose.ui.input.nestedscroll.nestedScroll\r\nimport androidx.compose.ui.tooling.preview.Preview\r\nimport androidx.compose.ui.unit.dp\r\nimport me.neko.nzhelper.ui.util.AboutDialog\r\n\r\n@OptIn(ExperimentalMaterial3Api::class)\r\n@Composable\r\nfun PreferenceItem(\r\n title: String,\r\n summary: String? = null,\r\n icon: @Composable (() -> Unit)? = null,\r\n onClick: () -> Unit,\r\n) {\r\n ListItem(\r\n modifier = Modifier\r\n .fillMaxWidth()\r\n .clickable(onClick = onClick),\r\n leadingContent = icon,\r\n headlineContent = { Text(text = title, style = MaterialTheme.typography.bodyLarge) },\r\n supportingContent = summary\r\n ?.let { { Text(text = it, style = MaterialTheme.typography.bodyMedium) } }\r\n )\r\n}\r\n\r\n@OptIn(ExperimentalMaterial3Api::class)\r\n@Composable\r\nfun SettingsScreen() {\r\n var showAboutDialog by remember { mutableStateOf(false) }\r\n val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())\r\n\r\n Scaffold(\r\n topBar = {\r\n TopAppBar(\r\n title = { Text(\"设置\") },\r\n scrollBehavior = scrollBehavior\r\n )\r\n },\r\n contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal)\r\n ) { innerPadding ->\r\n Column(\r\n modifier = Modifier\r\n .fillMaxSize()\r\n .padding(innerPadding)\r\n .nestedScroll(scrollBehavior.nestedScrollConnection)\r\n ) {\r\n Text(\r\n text = \"常规\",\r\n modifier = Modifier.padding(start = 16.dp, top = 24.dp, bottom = 8.dp),\r\n style = MaterialTheme.typography.labelLarge,\r\n color = MaterialTheme.colorScheme.primary\r\n )\r\n\r\n PreferenceItem(\r\n title = \"关于\",\r\n summary = null,\r\n icon = { Icon(Icons.Default.Info, contentDescription = null) },\r\n onClick = { showAboutDialog = true }\r\n )\r\n\r\n Spacer(modifier = Modifier.weight(1f))\r\n }\r\n\r\n if (showAboutDialog) {\r\n AboutDialog(onDismiss = { showAboutDialog = false })\r\n }\r\n }\r\n}\r\n\r\n@Preview(showBackground = true)\r\n@Composable\r\nfun SettingsScreenPreview() {\r\n SettingsScreen()\r\n}\r\n 101 | Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP 102 | <+>UTF-8 103 | =================================================================== 104 | diff --git a/app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt b/app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt 105 | --- a/app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt (revision 53dbb1212b49f88df6f6d0cd68e480b80ae8ac3e) 106 | +++ b/app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt (date 1752119502887) 107 | @@ -12,6 +12,7 @@ 108 | import androidx.compose.foundation.layout.safeDrawing 109 | import androidx.compose.material.icons.Icons 110 | import androidx.compose.material.icons.filled.Info 111 | +import androidx.compose.material.icons.outlined.Info 112 | import androidx.compose.material3.ExperimentalMaterial3Api 113 | import androidx.compose.material3.Icon 114 | import androidx.compose.material3.ListItem 115 | @@ -22,39 +23,17 @@ 116 | import androidx.compose.material3.TopAppBarDefaults 117 | import androidx.compose.material3.rememberTopAppBarState 118 | import androidx.compose.runtime.Composable 119 | -import androidx.compose.runtime.getValue 120 | -import androidx.compose.runtime.mutableStateOf 121 | -import androidx.compose.runtime.remember 122 | -import androidx.compose.runtime.setValue 123 | import androidx.compose.ui.Modifier 124 | import androidx.compose.ui.input.nestedscroll.nestedScroll 125 | import androidx.compose.ui.tooling.preview.Preview 126 | -import androidx.compose.ui.unit.dp 127 | -import me.neko.nzhelper.ui.util.AboutDialog 128 | - 129 | -@OptIn(ExperimentalMaterial3Api::class) 130 | -@Composable 131 | -fun PreferenceItem( 132 | - title: String, 133 | - summary: String? = null, 134 | - icon: @Composable (() -> Unit)? = null, 135 | - onClick: () -> Unit, 136 | -) { 137 | - ListItem( 138 | - modifier = Modifier 139 | - .fillMaxWidth() 140 | - .clickable(onClick = onClick), 141 | - leadingContent = icon, 142 | - headlineContent = { Text(text = title, style = MaterialTheme.typography.bodyLarge) }, 143 | - supportingContent = summary 144 | - ?.let { { Text(text = it, style = MaterialTheme.typography.bodyMedium) } } 145 | - ) 146 | -} 147 | +import androidx.navigation.NavController 148 | +import androidx.navigation.compose.rememberNavController 149 | 150 | @OptIn(ExperimentalMaterial3Api::class) 151 | @Composable 152 | -fun SettingsScreen() { 153 | - var showAboutDialog by remember { mutableStateOf(false) } 154 | +fun SettingsScreen( 155 | + navController: NavController 156 | +) { 157 | val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) 158 | 159 | Scaffold( 160 | @@ -72,31 +51,33 @@ 161 | .padding(innerPadding) 162 | .nestedScroll(scrollBehavior.nestedScrollConnection) 163 | ) { 164 | - Text( 165 | - text = "常规", 166 | - modifier = Modifier.padding(start = 16.dp, top = 24.dp, bottom = 8.dp), 167 | - style = MaterialTheme.typography.labelLarge, 168 | - color = MaterialTheme.colorScheme.primary 169 | - ) 170 | - 171 | - PreferenceItem( 172 | - title = "关于", 173 | - summary = null, 174 | - icon = { Icon(Icons.Default.Info, contentDescription = null) }, 175 | - onClick = { showAboutDialog = true } 176 | + ListItem( 177 | + modifier = Modifier 178 | + .fillMaxWidth() 179 | + .clickable { 180 | + navController.navigate("about") 181 | + }, 182 | + leadingContent = { 183 | + Icon( 184 | + imageVector = Icons.Outlined.Info, 185 | + contentDescription = null, 186 | + ) 187 | + }, 188 | + headlineContent = { 189 | + Text(text = "关于", style = MaterialTheme.typography.bodyLarge) 190 | + } 191 | ) 192 | 193 | Spacer(modifier = Modifier.weight(1f)) 194 | } 195 | 196 | - if (showAboutDialog) { 197 | - AboutDialog(onDismiss = { showAboutDialog = false }) 198 | - } 199 | } 200 | } 201 | 202 | @Preview(showBackground = true) 203 | @Composable 204 | fun SettingsScreenPreview() { 205 | - SettingsScreen() 206 | + SettingsScreen( 207 | + navController = rememberNavController() 208 | + ) 209 | } 210 | Index: app/src/main/java/me/neko/nzhelper/ui/util/AboutDialog.kt 211 | =================================================================== 212 | diff --git a/app/src/main/java/me/neko/nzhelper/ui/util/AboutDialog.kt b/app/src/main/java/me/neko/nzhelper/ui/util/AboutDialog.kt 213 | deleted file mode 100644 214 | --- a/app/src/main/java/me/neko/nzhelper/ui/util/AboutDialog.kt (revision 53dbb1212b49f88df6f6d0cd68e480b80ae8ac3e) 215 | +++ /dev/null (revision 53dbb1212b49f88df6f6d0cd68e480b80ae8ac3e) 216 | @@ -1,138 +0,0 @@ 217 | -package me.neko.nzhelper.ui.util 218 | - 219 | -import androidx.compose.foundation.Image 220 | -import androidx.compose.foundation.layout.Column 221 | -import androidx.compose.foundation.layout.Spacer 222 | -import androidx.compose.foundation.layout.height 223 | -import androidx.compose.foundation.layout.size 224 | -import androidx.compose.material3.AlertDialog 225 | -import androidx.compose.material3.ExperimentalMaterial3Api 226 | -import androidx.compose.material3.Text 227 | -import androidx.compose.material3.TextButton 228 | -import androidx.compose.runtime.Composable 229 | -import androidx.compose.runtime.mutableStateOf 230 | -import androidx.compose.runtime.remember 231 | -import androidx.compose.ui.Alignment 232 | -import androidx.compose.ui.Modifier 233 | -import androidx.compose.ui.platform.LocalContext 234 | -import androidx.compose.ui.platform.LocalUriHandler 235 | -import androidx.compose.ui.res.painterResource 236 | -import androidx.compose.ui.text.LinkAnnotation 237 | -import androidx.compose.ui.text.SpanStyle 238 | -import androidx.compose.ui.text.TextStyle 239 | -import androidx.compose.ui.text.buildAnnotatedString 240 | -import androidx.compose.ui.text.style.TextDecoration 241 | -import androidx.compose.ui.unit.dp 242 | -import androidx.compose.ui.window.DialogProperties 243 | -import me.neko.nzhelper.R 244 | - 245 | -@OptIn(ExperimentalMaterial3Api::class) 246 | -@Composable 247 | -fun AboutDialog(onDismiss: () -> Unit) { 248 | - val context = LocalContext.current 249 | - val versionName = remember { 250 | - context.packageManager 251 | - .getPackageInfo(context.packageName, 0) 252 | - .versionName 253 | - } 254 | - val uriHandler = LocalUriHandler.current 255 | - val url = "https://github.com/zzzdajb/DickHelper" 256 | - val label = "DickHelper" 257 | - 258 | - val sourceLabel = "GitHub" 259 | - val sourceUrl = "https://github.com/bug-bit/NzHelper" 260 | - 261 | - val showDonateDialog = remember { mutableStateOf(false) } 262 | - 263 | - val annotated = buildAnnotatedString { 264 | - append("这是一个以开源项目 ") 265 | - 266 | - val start = length 267 | - append(label) 268 | - val end = length 269 | - 270 | - addStyle( 271 | - style = SpanStyle(textDecoration = TextDecoration.Underline), 272 | - start = start, 273 | - end = end 274 | - ) 275 | - addLink( 276 | - LinkAnnotation.Clickable( 277 | - tag = label, 278 | - linkInteractionListener = { uriHandler.openUri(url) } 279 | - ), 280 | - start = start, 281 | - end = end 282 | - ) 283 | - 284 | - append(" 作为参考的使用 Kotlin 编写的 App") 285 | - } 286 | - val viewSource = buildAnnotatedString { 287 | - append("在 ") 288 | - val start = length 289 | - append(sourceLabel) 290 | - val end = length 291 | - addStyle( 292 | - style = SpanStyle(textDecoration = TextDecoration.Underline), 293 | - start = start, 294 | - end = end 295 | - ) 296 | - addLink( 297 | - LinkAnnotation.Clickable( 298 | - tag = sourceLabel, 299 | - linkInteractionListener = { uriHandler.openUri(sourceUrl) } 300 | - ), 301 | - start = start, 302 | - end = end 303 | - ) 304 | - append(" 查看源码") 305 | - } 306 | - 307 | - AlertDialog( 308 | - onDismissRequest = onDismiss, 309 | - title = { Text("关于本应用") }, 310 | - text = { 311 | - Column { 312 | - Text("版本:$versionName") 313 | - Spacer(Modifier.height(8.dp)) 314 | - Text(text = annotated, style = TextStyle()) 315 | - Spacer(Modifier.height(8.dp)) 316 | - Text(text = viewSource, style = TextStyle()) 317 | - } 318 | - }, 319 | - confirmButton = { 320 | - TextButton(onClick = onDismiss) { 321 | - Text("确定") 322 | - } 323 | - }, 324 | - dismissButton = { 325 | - TextButton(onClick = { showDonateDialog.value = true }) { 326 | - Text("捐赠打赏") 327 | - } 328 | - }, 329 | - properties = DialogProperties(usePlatformDefaultWidth = true) 330 | - ) 331 | - 332 | - if (showDonateDialog.value) { 333 | - AlertDialog( 334 | - onDismissRequest = { showDonateDialog.value = false }, 335 | - title = { Text("打赏我们") }, 336 | - text = { 337 | - Column(horizontalAlignment = Alignment.CenterHorizontally) { 338 | - Text("祝愿所有给我们打赏的小伙伴牛子长度翻倍 ❤️ 您的捐赠将是我们更新的动力") 339 | - Spacer(Modifier.height(16.dp)) 340 | - Image( 341 | - painter = painterResource(id = R.drawable.weixin), 342 | - contentDescription = "QR Code", 343 | - modifier = Modifier.size(200.dp) 344 | - ) 345 | - } 346 | - }, 347 | - confirmButton = { 348 | - TextButton(onClick = { showDonateDialog.value = false }) { 349 | - Text("知道了") 350 | - } 351 | - } 352 | - ) 353 | - } 354 | -} 355 | Index: .idea/vcs.xml 356 | IDEA additional info: 357 | Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP 358 | <+>\r\n\r\n \r\n \r\n \r\n 359 | Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP 360 | <+>UTF-8 361 | =================================================================== 362 | diff --git a/.idea/vcs.xml b/.idea/vcs.xml 363 | --- a/.idea/vcs.xml (revision 53dbb1212b49f88df6f6d0cd68e480b80ae8ac3e) 364 | +++ b/.idea/vcs.xml (date 1752070295518) 365 | @@ -1,6 +1,6 @@ 366 | 367 | 368 | 369 | - 370 | + 371 | 372 | 373 | \ No newline at end of file 374 | Index: app/src/main/res/drawable/code_24px.xml 375 | IDEA additional info: 376 | Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP 377 | <+>UTF-8 378 | =================================================================== 379 | diff --git a/app/src/main/res/drawable/code_24px.xml b/app/src/main/res/drawable/code_24px.xml 380 | new file mode 100644 381 | --- /dev/null (date 1752118807449) 382 | +++ b/app/src/main/res/drawable/code_24px.xml (date 1752118807449) 383 | @@ -0,0 +1,9 @@ 384 | + 389 | + 392 | + 393 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_10_11_56__Changes_.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_4_18_05_[Changes]/shelved.patch: -------------------------------------------------------------------------------- 1 | Index: app/release/output-metadata.json 2 | IDEA additional info: 3 | Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP 4 | <+>{\r\n \"version\": 3,\r\n \"artifactType\": {\r\n \"type\": \"APK\",\r\n \"kind\": \"Directory\"\r\n },\r\n \"applicationId\": \"me.neko.nzhelper\",\r\n \"variantName\": \"release\",\r\n \"elements\": [\r\n {\r\n \"type\": \"SINGLE\",\r\n \"filters\": [],\r\n \"attributes\": [],\r\n \"versionCode\": 29,\r\n \"versionName\": \"0.0.9-alpha.r29.eb114e6\",\r\n \"outputFile\": \"NzHelper_v0.0.9-alpha.r29.eb114e6.apk\"\r\n }\r\n ],\r\n \"elementType\": \"File\",\r\n \"baselineProfiles\": [\r\n {\r\n \"minApi\": 28,\r\n \"maxApi\": 30,\r\n \"baselineProfiles\": [\r\n \"baselineProfiles/1/NzHelper_v0.0.9-alpha.r29.eb114e6.dm\"\r\n ]\r\n },\r\n {\r\n \"minApi\": 31,\r\n \"maxApi\": 2147483647,\r\n \"baselineProfiles\": [\r\n \"baselineProfiles/0/NzHelper_v0.0.9-alpha.r29.eb114e6.dm\"\r\n ]\r\n }\r\n ],\r\n \"minSdkVersionForDexing\": 26\r\n} 5 | =================================================================== 6 | diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json 7 | --- a/app/release/output-metadata.json (revision 7b0a7ec41344817c2ac19b2a351270ee1af8a77f) 8 | +++ b/app/release/output-metadata.json (date 1751623177181) 9 | @@ -11,9 +11,9 @@ 10 | "type": "SINGLE", 11 | "filters": [], 12 | "attributes": [], 13 | - "versionCode": 29, 14 | - "versionName": "0.0.9-alpha.r29.eb114e6", 15 | - "outputFile": "NzHelper_v0.0.9-alpha.r29.eb114e6.apk" 16 | + "versionCode": 36, 17 | + "versionName": "0.0.9-alpha.r36.7b0a7ec", 18 | + "outputFile": "NzHelper_v0.0.9-alpha.r36.7b0a7ec.apk" 19 | } 20 | ], 21 | "elementType": "File", 22 | @@ -22,14 +22,14 @@ 23 | "minApi": 28, 24 | "maxApi": 30, 25 | "baselineProfiles": [ 26 | - "baselineProfiles/1/NzHelper_v0.0.9-alpha.r29.eb114e6.dm" 27 | + "baselineProfiles/1/NzHelper_v0.0.9-alpha.r36.7b0a7ec.dm" 28 | ] 29 | }, 30 | { 31 | "minApi": 31, 32 | "maxApi": 2147483647, 33 | "baselineProfiles": [ 34 | - "baselineProfiles/0/NzHelper_v0.0.9-alpha.r29.eb114e6.dm" 35 | + "baselineProfiles/0/NzHelper_v0.0.9-alpha.r36.7b0a7ec.dm" 36 | ] 37 | } 38 | ], 39 | -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_4_18_05_[Changes]1/shelved.patch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_4_18_05_[Changes]1/shelved.patch -------------------------------------------------------------------------------- /.idea/shelf/Uncommitted_changes_before_Update_at_2025_7_4_18_05__Changes_.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ![NzHelper](https://socialify.git.ci/bug-bit/NzHelper/image?description=1&font=Inter&forks=1&language=1&name=1&owner=1&stargazers=1&theme=Auto) 4 | 5 | # NzHelper 6 | 7 | [![license](https://img.shields.io/github/license/bug-bit/NzHelper.svg)](https://www.gnu.org/licenses/gpl-3.0.html) 8 | [![Stars](https://img.shields.io/github/stars/bug-bit/NzHelper?label=stars)](https://github.com/bug-bit/NzHelper) 9 | GitHub all releases 10 | [![GitHub Release](https://img.shields.io/github/v/release/bug-bit/NzHelper)](https://github.com/bug-bit/NzHelper/releases) 11 | GitHub issues 12 | 13 | 一个简单、高效、易用的打飞机记录工具,帮助你科学管理✈️生活 14 | 15 |
16 | 17 | --- 18 | 19 | ## 说明 20 | > 在 GitHub 点击 ⭐ Star 以支持我在空余时间继续开发 21 | > 祝愿所有给本项目Star的小伙伴牛子长度翻倍! 22 | 23 | - 本项目参考了以下开源项目: 24 | - [DickHelper](https://github.com/zzzdajb/DickHelper) 25 | 26 | 27 | ## 贡献 28 | 欢迎提交 issue 或 pull request 以改进本项目。 29 | 30 | --- 31 | 32 | ## Star History 33 | 34 | [![Star History Chart](https://api.star-history.com/svg?repos=bug-bit/NzHelper&type=Timeline)](https://star-history.com/#bug-bit/NzHelper&Timeline) 35 | 36 | ## 许可协议 37 | 38 | 本项目基于 GNU 通用公共许可证 第3版(GPLv3)进行授权。 39 | 详情请查阅 [LICENSE](LICENSE) 文件。 40 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | build/ -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.application) 3 | alias(libs.plugins.kotlin.android) 4 | alias(libs.plugins.kotlin.compose) 5 | } 6 | 7 | fun getGitCommitCount(): Int { 8 | return try { 9 | val process = ProcessBuilder("git", "rev-list", "--count", "HEAD") 10 | .redirectErrorStream(true) 11 | .start() 12 | process.inputStream.bufferedReader().readText().trim().toInt() 13 | } catch (_: Exception) { 14 | 1 // fallback 15 | } 16 | } 17 | 18 | fun getGitShortHash(): String { 19 | return try { 20 | val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD") 21 | .redirectErrorStream(true) 22 | .start() 23 | process.inputStream.bufferedReader().readText().trim() 24 | } catch (_: Exception) { 25 | "unknown" 26 | } 27 | } 28 | 29 | android { 30 | namespace = "me.neko.nzhelper" 31 | compileSdk = 36 32 | 33 | defaultConfig { 34 | applicationId = "me.neko.nzhelper" 35 | minSdk = 26 36 | targetSdk = 36 37 | 38 | val commitCount = getGitCommitCount() 39 | val gitHash = getGitShortHash() 40 | 41 | versionCode = getGitCommitCount() 42 | versionName = "0.0.13-alpha.r$commitCount.$gitHash" 43 | 44 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 45 | } 46 | 47 | buildTypes { 48 | release { 49 | isMinifyEnabled = true 50 | isShrinkResources = true // 移除无用资源 51 | proguardFiles( 52 | getDefaultProguardFile("proguard-android-optimize.txt"), 53 | "proguard-rules.pro" 54 | ) 55 | } 56 | } 57 | compileOptions { 58 | sourceCompatibility = JavaVersion.VERSION_11 59 | targetCompatibility = JavaVersion.VERSION_11 60 | } 61 | kotlin { 62 | compilerOptions { 63 | jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11) 64 | } 65 | } 66 | buildFeatures { 67 | compose = true 68 | buildConfig = true 69 | } 70 | 71 | // 构建时的包名 72 | android.applicationVariants.all { 73 | outputs.all { 74 | if (this is com.android.build.gradle.internal.api.ApkVariantOutputImpl) { 75 | val config = project.android.defaultConfig 76 | val versionName = config.versionName 77 | this.outputFileName = "NzHelper_v${versionName}.apk" 78 | } 79 | } 80 | } 81 | 82 | } 83 | 84 | dependencies { 85 | 86 | implementation(libs.androidx.core.ktx) 87 | implementation(libs.androidx.lifecycle.runtime.ktx) 88 | implementation(libs.androidx.activity.compose) 89 | implementation(platform(libs.androidx.compose.bom)) 90 | implementation(libs.androidx.ui) 91 | implementation(libs.androidx.ui.graphics) 92 | implementation(libs.androidx.ui.tooling.preview) 93 | implementation(libs.androidx.material3) 94 | implementation(libs.androidx.navigation.compose) 95 | implementation(libs.gson) 96 | implementation(libs.okhttp) 97 | implementation(libs.moshi) 98 | implementation(libs.moshi.kotlin) 99 | testImplementation(libs.junit) 100 | androidTestImplementation(libs.androidx.junit) 101 | androidTestImplementation(libs.androidx.espresso.core) 102 | androidTestImplementation(platform(libs.androidx.compose.bom)) 103 | androidTestImplementation(libs.androidx.ui.test.junit4) 104 | debugImplementation(libs.androidx.ui.tooling) 105 | debugImplementation(libs.androidx.ui.test.manifest) 106 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | # Keep OkHttp3 classes 24 | -dontwarn okhttp3.** 25 | -keep class okhttp3.** { *; } 26 | -keep interface okhttp3.** { *; } 27 | 28 | # 保留所有 Moshi codegen 生成的 JsonAdapter 类 29 | -keep class *JsonAdapter { 30 | (...); 31 | *; 32 | } 33 | -keep class me.neko.nzhelper.ui.util.*JsonAdapter { 34 | (...); 35 | *; 36 | } 37 | # 保留 data class(可选,通常反射也需要) 38 | -keep class me.neko.nzhelper.ui.util.GitHubRelease { 39 | *; 40 | } 41 | -------------------------------------------------------------------------------- /app/src/androidTest/java/me/neko/nzhelper/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("me.neko.nzhelper", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.activity.enableEdgeToEdge 7 | import me.neko.nzhelper.ui.theme.NzHelperTheme 8 | import me.neko.nzhelper.ui.screens.MainScreen 9 | 10 | class MainActivity : ComponentActivity() { 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | enableEdgeToEdge() 14 | setContent { 15 | NzHelperTheme { 16 | MainScreen() 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/NzApplication.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper 2 | 3 | import android.app.Application 4 | import me.neko.nzhelper.ui.util.NotificationUtil 5 | 6 | class NzApplication : Application() { 7 | override fun onCreate() { 8 | super.onCreate() 9 | // 在应用启动时创建通知渠道 10 | NotificationUtil.createChannel(this) 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/data/SessionRepository.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.data 2 | 3 | import android.content.Context 4 | import androidx.core.content.edit 5 | import com.google.gson.Gson 6 | import com.google.gson.JsonParser 7 | import kotlinx.coroutines.Dispatchers 8 | import kotlinx.coroutines.withContext 9 | import java.time.LocalDateTime 10 | import java.time.format.DateTimeFormatter 11 | 12 | // 公共数据类 13 | data class Session( 14 | val timestamp: LocalDateTime, 15 | val duration: Int, 16 | val remark: String, 17 | val location: String, 18 | val watchedMovie: Boolean, 19 | val climax: Boolean, 20 | val rating: Float, 21 | val mood: String, 22 | val props: String 23 | ) 24 | 25 | // 序列化/反序列化和持久化 26 | object SessionRepository { 27 | private const val PREFS_NAME = "sessions_prefs" 28 | private const val KEY_SESSIONS = "sessions" 29 | private val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME 30 | private val gson = Gson() 31 | 32 | /** 33 | * 从 SharedPreferences 加载会话列表 34 | */ 35 | suspend fun loadSessions(context: Context): List = withContext(Dispatchers.IO) { 36 | val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) 37 | val jsonStr = prefs.getString(KEY_SESSIONS, "[]") ?: "[]" 38 | val root = JsonParser.parseString(jsonStr).asJsonArray 39 | val list = mutableListOf() 40 | for (elem in root) { 41 | if (elem.isJsonArray) { 42 | val arr = elem.asJsonArray 43 | val timeStr = arr[0].asString 44 | val dur = if (arr.size() >= 2) arr[1].asInt else 0 45 | val rem = if (arr.size() >= 3 && !arr[2].isJsonNull) arr[2].asString else "" 46 | val loc = if (arr.size() >= 4 && !arr[3].isJsonNull) arr[3].asString else "" 47 | val watched = if (arr.size() >= 5) arr[4].asBoolean else false 48 | val climaxed = if (arr.size() >= 6) arr[5].asBoolean else false 49 | val rate = if (arr.size() >= 7 && !arr[6].isJsonNull) { 50 | arr[6].asFloat.coerceIn(0f, 5f) // 确保在范围内 51 | } else 0f 52 | val md = if (arr.size() >= 8 && !arr[7].isJsonNull) arr[7].asString else "" 53 | val prop = if (arr.size() >= 9 && !arr[8].isJsonNull) arr[8].asString else "" 54 | list.add( 55 | Session( 56 | timestamp = LocalDateTime.parse(timeStr, formatter), 57 | duration = dur, 58 | remark = rem, 59 | location = loc, 60 | watchedMovie = watched, 61 | climax = climaxed, 62 | rating = rate, 63 | mood = md, 64 | props = prop 65 | ) 66 | ) 67 | } 68 | } 69 | list 70 | } 71 | 72 | /** 73 | * 将会话列表保存到 SharedPreferences 74 | */ 75 | suspend fun saveSessions(context: Context, sessions: List) = 76 | withContext(Dispatchers.IO) { 77 | val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) 78 | prefs.edit { 79 | val jsonArray = sessions.map { session -> 80 | listOf( 81 | session.timestamp.format(formatter), 82 | session.duration, 83 | session.remark, 84 | session.location, 85 | session.watchedMovie, 86 | session.climax, 87 | session.rating, 88 | session.mood, 89 | session.props 90 | ) 91 | } 92 | val jsonStr = gson.toJson(jsonArray) 93 | putString(KEY_SESSIONS, jsonStr) 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/AboutScreen.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import android.content.Intent 4 | import android.content.pm.PackageManager 5 | import androidx.compose.foundation.Image 6 | import androidx.compose.foundation.clickable 7 | import androidx.compose.foundation.layout.Arrangement 8 | import androidx.compose.foundation.layout.Column 9 | import androidx.compose.foundation.layout.Row 10 | import androidx.compose.foundation.layout.Spacer 11 | import androidx.compose.foundation.layout.WindowInsets 12 | import androidx.compose.foundation.layout.WindowInsetsSides 13 | import androidx.compose.foundation.layout.fillMaxSize 14 | import androidx.compose.foundation.layout.fillMaxWidth 15 | import androidx.compose.foundation.layout.height 16 | import androidx.compose.foundation.layout.only 17 | import androidx.compose.foundation.layout.padding 18 | import androidx.compose.foundation.layout.safeDrawing 19 | import androidx.compose.foundation.layout.size 20 | import androidx.compose.foundation.layout.width 21 | import androidx.compose.foundation.lazy.LazyColumn 22 | import androidx.compose.foundation.shape.RoundedCornerShape 23 | import androidx.compose.material.icons.Icons 24 | import androidx.compose.material.icons.automirrored.filled.ArrowBack 25 | import androidx.compose.material3.DividerDefaults 26 | import androidx.compose.material3.ExperimentalMaterial3Api 27 | import androidx.compose.material3.HorizontalDivider 28 | import androidx.compose.material3.Icon 29 | import androidx.compose.material3.IconButton 30 | import androidx.compose.material3.MaterialTheme 31 | import androidx.compose.material3.Scaffold 32 | import androidx.compose.material3.Text 33 | import androidx.compose.material3.TopAppBar 34 | import androidx.compose.material3.TopAppBarDefaults.pinnedScrollBehavior 35 | import androidx.compose.material3.rememberTopAppBarState 36 | import androidx.compose.runtime.Composable 37 | import androidx.compose.runtime.remember 38 | import androidx.compose.ui.Alignment 39 | import androidx.compose.ui.Modifier 40 | import androidx.compose.ui.draw.clip 41 | import androidx.compose.ui.graphics.asImageBitmap 42 | import androidx.compose.ui.graphics.painter.BitmapPainter 43 | import androidx.compose.ui.input.nestedscroll.nestedScroll 44 | import androidx.compose.ui.platform.LocalContext 45 | import androidx.compose.ui.platform.LocalInspectionMode 46 | import androidx.compose.ui.res.painterResource 47 | import androidx.compose.ui.res.stringResource 48 | import androidx.compose.ui.tooling.preview.Preview 49 | import androidx.compose.ui.unit.dp 50 | import androidx.core.content.ContextCompat 51 | import androidx.core.graphics.drawable.toBitmap 52 | import androidx.core.net.toUri 53 | import androidx.navigation.NavHostController 54 | import androidx.navigation.compose.rememberNavController 55 | import me.neko.nzhelper.R 56 | 57 | @OptIn(ExperimentalMaterial3Api::class) 58 | @Composable 59 | fun AboutScreen( 60 | navController: NavHostController 61 | ) { 62 | val scrollBehavior = pinnedScrollBehavior(rememberTopAppBarState()) 63 | val context = LocalContext.current 64 | val isInPreview = LocalInspectionMode.current 65 | val versionName = remember(context, isInPreview) { 66 | if (isInPreview) { 67 | "预览版" 68 | } else { 69 | try { 70 | context.packageManager 71 | .getPackageInfo(context.packageName, 0) 72 | .versionName 73 | ?: "未知版本" 74 | } catch (_: PackageManager.NameNotFoundException) { 75 | "未知版本" 76 | } 77 | } 78 | } 79 | 80 | Scaffold( 81 | topBar = { 82 | TopAppBar( 83 | title = { Text("关于") }, 84 | navigationIcon = { 85 | IconButton(onClick = { navController.popBackStack() }) { 86 | Icon( 87 | imageVector = Icons.AutoMirrored.Filled.ArrowBack, 88 | contentDescription = "返回" 89 | ) 90 | } 91 | }, 92 | scrollBehavior = scrollBehavior 93 | ) 94 | }, 95 | contentWindowInsets = WindowInsets.safeDrawing 96 | .only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) 97 | ) { innerPadding -> 98 | LazyColumn( 99 | modifier = Modifier 100 | .fillMaxSize() 101 | .padding(innerPadding) 102 | .nestedScroll(scrollBehavior.nestedScrollConnection), 103 | horizontalAlignment = Alignment.CenterHorizontally, 104 | verticalArrangement = Arrangement.Top 105 | ) { 106 | item { 107 | Spacer(Modifier.height(20.dp)) 108 | } 109 | 110 | item { 111 | val context = LocalContext.current 112 | val icon = remember { 113 | val drawable = ContextCompat.getDrawable(context, R.mipmap.ic_launcher)!! 114 | BitmapPainter(drawable.toBitmap().asImageBitmap()) 115 | } 116 | Image( 117 | painter = icon, 118 | contentDescription = null, 119 | modifier = Modifier 120 | .size(90.dp) 121 | .clip(RoundedCornerShape(16.dp)) 122 | ) 123 | } 124 | item { 125 | Spacer(Modifier.height(16.dp)) 126 | } 127 | 128 | item { 129 | Text( 130 | text = stringResource(R.string.app_name), 131 | style = MaterialTheme.typography.titleLarge 132 | ) 133 | } 134 | item { 135 | Spacer(Modifier.height(8.dp)) 136 | } 137 | 138 | item { 139 | Text( 140 | text = "版本: $versionName", 141 | style = MaterialTheme.typography.bodyMedium, 142 | ) 143 | } 144 | 145 | item { 146 | HorizontalDivider( 147 | modifier = Modifier 148 | .fillMaxWidth() 149 | .padding(horizontal = 32.dp, vertical = 24.dp), 150 | thickness = DividerDefaults.Thickness, color = DividerDefaults.color 151 | ) 152 | } 153 | 154 | item { 155 | val context = LocalContext.current 156 | Row( 157 | modifier = Modifier 158 | .fillMaxWidth() 159 | .clickable { 160 | val intent = Intent( 161 | Intent.ACTION_VIEW, 162 | "https://github.com/bug-bit/NzHelper".toUri() 163 | ) 164 | context.startActivity(intent) 165 | } 166 | .padding(16.dp), 167 | verticalAlignment = Alignment.CenterVertically 168 | ) { 169 | Icon( 170 | painter = painterResource(id = R.drawable.code_24px), 171 | contentDescription = null, 172 | modifier = Modifier.size(24.dp) 173 | ) 174 | 175 | Spacer(modifier = Modifier.width(16.dp)) 176 | 177 | Column { 178 | Text( 179 | text = "仓库", 180 | style = MaterialTheme.typography.titleMedium 181 | ) 182 | Text( 183 | text = "在GitHub仓库查看源码", 184 | style = MaterialTheme.typography.bodyMedium 185 | ) 186 | } 187 | } 188 | } 189 | item { 190 | Column { 191 | Row( 192 | modifier = Modifier 193 | .fillMaxWidth() 194 | .clickable { 195 | navController.navigate("open_source") 196 | } 197 | .padding(16.dp), 198 | verticalAlignment = Alignment.CenterVertically 199 | ) { 200 | Icon( 201 | painter = painterResource(id = R.drawable.source_code_24px), 202 | contentDescription = null, 203 | modifier = Modifier.size(24.dp) 204 | ) 205 | Spacer(modifier = Modifier.width(16.dp)) 206 | Column { 207 | Text( 208 | text = "开放源代码", 209 | style = MaterialTheme.typography.titleMedium 210 | ) 211 | } 212 | } 213 | } 214 | } 215 | } 216 | } 217 | } 218 | 219 | @Preview(showBackground = true) 220 | @Composable 221 | fun AboutScreenPreview() { 222 | AboutScreen( 223 | navController = rememberNavController() 224 | ) 225 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/HistoryScreen.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.net.Uri 6 | import androidx.activity.compose.rememberLauncherForActivityResult 7 | import androidx.activity.result.contract.ActivityResultContracts 8 | import androidx.compose.foundation.layout.Arrangement 9 | import androidx.compose.foundation.layout.Box 10 | import androidx.compose.foundation.layout.Column 11 | import androidx.compose.foundation.layout.PaddingValues 12 | import androidx.compose.foundation.layout.Row 13 | import androidx.compose.foundation.layout.WindowInsets 14 | import androidx.compose.foundation.layout.WindowInsetsSides 15 | import androidx.compose.foundation.layout.fillMaxSize 16 | import androidx.compose.foundation.layout.fillMaxWidth 17 | import androidx.compose.foundation.layout.only 18 | import androidx.compose.foundation.layout.padding 19 | import androidx.compose.foundation.layout.safeDrawing 20 | import androidx.compose.foundation.lazy.LazyColumn 21 | import androidx.compose.foundation.lazy.items 22 | import androidx.compose.material.icons.Icons 23 | import androidx.compose.material.icons.filled.Delete 24 | import androidx.compose.material.icons.filled.MoreVert 25 | import androidx.compose.material3.AlertDialog 26 | import androidx.compose.material3.CardDefaults 27 | import androidx.compose.material3.DropdownMenu 28 | import androidx.compose.material3.DropdownMenuItem 29 | import androidx.compose.material3.ExperimentalMaterial3Api 30 | import androidx.compose.material3.Icon 31 | import androidx.compose.material3.IconButton 32 | import androidx.compose.material3.MaterialTheme 33 | import androidx.compose.material3.OutlinedCard 34 | import androidx.compose.material3.Scaffold 35 | import androidx.compose.material3.Text 36 | import androidx.compose.material3.TextButton 37 | import androidx.compose.material3.TopAppBar 38 | import androidx.compose.material3.TopAppBarDefaults 39 | import androidx.compose.material3.rememberTopAppBarState 40 | import androidx.compose.runtime.Composable 41 | import androidx.compose.runtime.LaunchedEffect 42 | import androidx.compose.runtime.getValue 43 | import androidx.compose.runtime.mutableFloatStateOf 44 | import androidx.compose.runtime.mutableStateListOf 45 | import androidx.compose.runtime.mutableStateOf 46 | import androidx.compose.runtime.remember 47 | import androidx.compose.runtime.rememberCoroutineScope 48 | import androidx.compose.runtime.setValue 49 | import androidx.compose.ui.Alignment 50 | import androidx.compose.ui.Modifier 51 | import androidx.compose.ui.input.nestedscroll.nestedScroll 52 | import androidx.compose.ui.platform.LocalContext 53 | import androidx.compose.ui.tooling.preview.Preview 54 | import androidx.compose.ui.unit.dp 55 | import androidx.core.content.edit 56 | import com.google.gson.Gson 57 | import com.google.gson.JsonParser 58 | import kotlinx.coroutines.launch 59 | import me.neko.nzhelper.data.Session 60 | import me.neko.nzhelper.data.SessionRepository 61 | import java.io.OutputStreamWriter 62 | import java.time.LocalDateTime 63 | import java.time.format.DateTimeFormatter 64 | 65 | @SuppressLint("DefaultLocale") 66 | private fun formatTime(totalSeconds: Int): String { 67 | val hours = totalSeconds / 3600 68 | val minutes = (totalSeconds % 3600) / 60 69 | val seconds = totalSeconds % 60 70 | return buildString { 71 | if (hours > 0) append(String.format("%02d:", hours)) 72 | append(String.format("%02d:%02d", minutes, seconds)) 73 | } 74 | } 75 | 76 | @OptIn(ExperimentalMaterial3Api::class) 77 | @Composable 78 | fun HistoryScreen() { 79 | val context = LocalContext.current 80 | val prefs = remember { context.getSharedPreferences("sessions_prefs", Context.MODE_PRIVATE) } 81 | val gson = remember { Gson() } 82 | val formatter = remember { DateTimeFormatter.ISO_LOCAL_DATE_TIME } 83 | val sessions = remember { mutableStateListOf() } 84 | 85 | val scope = rememberCoroutineScope() 86 | var editSession by remember { mutableStateOf(null) } 87 | var showDetailsDialog by remember { mutableStateOf(false) } 88 | var isEditing by remember { mutableStateOf(false) } 89 | 90 | var remarkInput by remember { mutableStateOf("") } 91 | var locationInput by remember { mutableStateOf("") } 92 | var watchedMovie by remember { mutableStateOf(false) } 93 | var climax by remember { mutableStateOf(false) } 94 | var rating by remember { mutableFloatStateOf(3f) } 95 | var mood by remember { mutableStateOf("平静") } 96 | var props by remember { mutableStateOf("手") } 97 | 98 | var showMenu by remember { mutableStateOf(false) } 99 | var showClearDialog by remember { mutableStateOf(false) } 100 | var sessionToDelete by remember { mutableStateOf(null) } 101 | var sessionToView by remember { mutableStateOf(null) } 102 | val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) 103 | 104 | // 导出 Launcher 105 | val exportLauncher = rememberLauncherForActivityResult( 106 | contract = ActivityResultContracts.CreateDocument("application/json") 107 | ) { uri: Uri? -> 108 | uri?.let { 109 | context.contentResolver.openOutputStream(it)?.use { os -> 110 | OutputStreamWriter(os).use { writer -> 111 | // 序列化 112 | val outList = sessions.map { s -> 113 | listOf( 114 | s.timestamp.format(formatter), 115 | s.duration, 116 | s.remark, 117 | s.location, 118 | s.watchedMovie, 119 | s.climax, 120 | s.rating, 121 | s.mood, 122 | s.props 123 | ) 124 | } 125 | writer.write(gson.toJson(outList)) 126 | } 127 | } 128 | } 129 | } 130 | 131 | // 导入 Launcher 132 | val importLauncher = rememberLauncherForActivityResult( 133 | contract = ActivityResultContracts.OpenDocument() 134 | ) { uri: Uri? -> 135 | uri?.let { 136 | context.contentResolver.openInputStream(it) 137 | ?.bufferedReader() 138 | ?.use { reader -> 139 | val jsonStr = reader.readText() 140 | val root = JsonParser.parseString(jsonStr).asJsonArray 141 | 142 | sessions.clear() 143 | 144 | for (elem in root) { 145 | if (elem.isJsonArray) { 146 | val arr = elem.asJsonArray 147 | val timeStr = arr[0].asString 148 | val dur = if (arr.size() >= 2) arr[1].asInt else 0 149 | val rem = 150 | if (arr.size() >= 3 && !arr[2].isJsonNull) arr[2].asString else "" 151 | val loc = 152 | if (arr.size() >= 4 && !arr[3].isJsonNull) arr[3].asString else "" 153 | val watched = if (arr.size() >= 5) arr[4].asBoolean else false 154 | val climaxed = if (arr.size() >= 6) arr[5].asBoolean else false 155 | val rate = if (arr.size() >= 7 && !arr[6].isJsonNull) { 156 | arr[6].asFloat.coerceIn(0f, 5f) // 确保在范围内 157 | } else 0f 158 | val md = 159 | if (arr.size() >= 8 && !arr[7].isJsonNull) arr[7].asString else "" 160 | val prop = 161 | if (arr.size() >= 9 && !arr[8].isJsonNull) arr[8].asString else "" 162 | sessions.add( 163 | Session( 164 | timestamp = LocalDateTime.parse(timeStr, formatter), 165 | duration = dur, 166 | remark = rem, 167 | location = loc, 168 | watchedMovie = watched, 169 | climax = climaxed, 170 | rating = rate, 171 | mood = md, 172 | props = prop 173 | ) 174 | ) 175 | } 176 | } 177 | 178 | prefs.edit { 179 | putString("sessions", jsonStr) 180 | } 181 | } 182 | } 183 | } 184 | 185 | // 读取历史(兼容旧版) 186 | LaunchedEffect(Unit) { 187 | val loaded = SessionRepository.loadSessions(context) 188 | sessions.clear() 189 | sessions.addAll(loaded) 190 | } 191 | 192 | Scaffold( 193 | topBar = { 194 | TopAppBar( 195 | title = { Text("历史记录") }, 196 | actions = { 197 | IconButton(onClick = { showMenu = true }) { 198 | Icon(Icons.Default.MoreVert, contentDescription = "更多") 199 | } 200 | DropdownMenu( 201 | expanded = showMenu, 202 | onDismissRequest = { showMenu = false } 203 | ) { 204 | DropdownMenuItem( 205 | text = { Text("导出数据") }, 206 | onClick = { 207 | showMenu = false 208 | exportLauncher.launch("NzHelper_export.json") 209 | } 210 | ) 211 | DropdownMenuItem( 212 | text = { Text("导入数据") }, 213 | onClick = { 214 | showMenu = false 215 | importLauncher.launch(arrayOf("application/json")) 216 | } 217 | ) 218 | DropdownMenuItem( 219 | text = { Text("清除全部记录") }, 220 | onClick = { 221 | showMenu = false 222 | showClearDialog = true 223 | } 224 | ) 225 | } 226 | }, 227 | scrollBehavior = scrollBehavior 228 | ) 229 | }, 230 | contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) 231 | ) { innerPadding -> 232 | Box( 233 | modifier = Modifier 234 | .fillMaxSize() 235 | .padding(innerPadding) 236 | .nestedScroll(scrollBehavior.nestedScrollConnection), 237 | ) { 238 | if (sessions.isEmpty()) { 239 | Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { 240 | Text("暂无历史记录", style = MaterialTheme.typography.bodyLarge) 241 | } 242 | } else { 243 | LazyColumn( 244 | modifier = Modifier.fillMaxSize(), 245 | verticalArrangement = Arrangement.spacedBy(8.dp), 246 | contentPadding = PaddingValues( 247 | top = 8.dp, 248 | start = 16.dp, 249 | end = 16.dp, 250 | bottom = 16.dp 251 | ) 252 | ) { 253 | items(sessions) { session -> 254 | OutlinedCard( 255 | modifier = Modifier.fillMaxWidth(), 256 | border = CardDefaults.outlinedCardBorder(), 257 | onClick = { sessionToView = session } 258 | ) { 259 | Column(modifier = Modifier.padding(16.dp)) { 260 | Row( 261 | verticalAlignment = Alignment.CenterVertically, 262 | horizontalArrangement = Arrangement.SpaceBetween, 263 | modifier = Modifier.fillMaxWidth() 264 | ) { 265 | Column { 266 | Text( 267 | "时间: ${ 268 | session.timestamp.format( 269 | DateTimeFormatter.ofPattern( 270 | "yyyy-MM-dd HH:mm:ss" 271 | ) 272 | ) 273 | }" 274 | ) 275 | Text("持续: ${formatTime(session.duration)}") 276 | if (session.remark.isNotEmpty()) { 277 | Text( 278 | "备注: ${session.remark}", 279 | style = MaterialTheme.typography.bodyMedium 280 | ) 281 | } 282 | } 283 | IconButton(onClick = { sessionToDelete = session }) { 284 | Icon(Icons.Default.Delete, contentDescription = "删除记录") 285 | } 286 | } 287 | } 288 | } 289 | } 290 | } 291 | } 292 | 293 | if (sessionToDelete != null) { 294 | AlertDialog( 295 | onDismissRequest = { sessionToDelete = null }, 296 | title = { Text("删除记录") }, 297 | text = { Text("确认删除此记录?") }, 298 | confirmButton = { 299 | TextButton(onClick = { 300 | sessions.remove(sessionToDelete) 301 | prefs.edit { 302 | putString( 303 | "sessions", 304 | gson.toJson(sessions.map { 305 | listOf( 306 | it.timestamp.format(formatter), 307 | it.duration, 308 | it.remark 309 | ) 310 | }) 311 | ) 312 | } 313 | sessionToDelete = null 314 | }) { Text("确认") } 315 | }, 316 | dismissButton = { 317 | TextButton(onClick = { sessionToDelete = null }) { Text("取消") } 318 | } 319 | ) 320 | } 321 | 322 | if (showClearDialog) { 323 | AlertDialog( 324 | onDismissRequest = { showClearDialog = false }, 325 | title = { Text("清除全部记录") }, 326 | text = { Text("确认要清除所有历史记录吗?此操作不可撤销。") }, 327 | confirmButton = { 328 | TextButton(onClick = { 329 | sessions.clear() 330 | prefs.edit { remove("sessions") } 331 | showClearDialog = false 332 | }) { Text("删除") } 333 | }, 334 | dismissButton = { 335 | TextButton(onClick = { showClearDialog = false }) { Text("取消") } 336 | } 337 | ) 338 | } 339 | 340 | // 查看详情对话框 341 | sessionToView?.let { s -> 342 | AlertDialog( 343 | onDismissRequest = { sessionToView = null }, 344 | title = { Text("会话详情") }, 345 | text = { 346 | Column { 347 | val pat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") 348 | Text("开始时间:${s.timestamp.format(pat)}") 349 | Text("持续时长:${formatTime(s.duration)}") 350 | Text("备注:${s.remark.ifEmpty { "无" }}") 351 | Text("地点:${s.location.ifEmpty { "无" }}") 352 | Text("是否观看小电影:${if (s.watchedMovie) "是" else "否"}") 353 | Text("发射:${if (s.climax) "是" else "否"}") 354 | Text("道具:${s.props.ifEmpty { "无" }}") 355 | Text("评分:${"%.1f".format(s.rating)} / 5.0") 356 | Text("心情:${s.mood.ifEmpty { "无" }}") 357 | } 358 | }, 359 | confirmButton = { 360 | TextButton(onClick = { sessionToView = null }) { Text("关闭") } 361 | }, 362 | dismissButton = { 363 | TextButton(onClick = { 364 | // 进入编辑状态 365 | editSession = s 366 | isEditing = true 367 | remarkInput = s.remark 368 | locationInput = s.location 369 | watchedMovie = s.watchedMovie 370 | climax = s.climax 371 | rating = s.rating 372 | mood = s.mood 373 | props = s.props 374 | showDetailsDialog = true 375 | sessionToView = null 376 | }) { Text("编辑") } 377 | } 378 | ) 379 | } 380 | // 编辑对话框复用 DetailsDialog 381 | DetailsDialog( 382 | show = showDetailsDialog, 383 | remark = remarkInput, 384 | onRemarkChange = { remarkInput = it }, 385 | location = locationInput, 386 | onLocationChange = { locationInput = it }, 387 | watchedMovie = watchedMovie, 388 | onWatchedMovieChange = { watchedMovie = it }, 389 | climax = climax, 390 | onClimaxChange = { climax = it }, 391 | props = props, 392 | onPropsChange = { props = it }, 393 | rating = rating, 394 | onRatingChange = { rating = it }, 395 | mood = mood, 396 | onMoodChange = { mood = it }, 397 | onConfirm = { 398 | if (isEditing && editSession != null) { 399 | // 更新列表中对应项 400 | val idx = sessions.indexOf(editSession!!) 401 | if (idx >= 0) { 402 | sessions[idx] = editSession!!.copy( 403 | remark = remarkInput, 404 | location = locationInput, 405 | watchedMovie = watchedMovie, 406 | climax = climax, 407 | rating = rating, 408 | mood = mood, 409 | props = props 410 | ) 411 | } 412 | } 413 | // 保存并重置 414 | scope.launch { SessionRepository.saveSessions(context, sessions) } 415 | remarkInput = ""; locationInput = ""; watchedMovie = false 416 | climax = false; rating = 3f; mood = "平静"; props = "手" 417 | showDetailsDialog = false; isEditing = false; editSession = null 418 | }, 419 | onDismiss = { 420 | showDetailsDialog = false; isEditing = false; editSession = null 421 | } 422 | ) 423 | } 424 | } 425 | } 426 | 427 | @OptIn(ExperimentalMaterial3Api::class) 428 | @Preview(showBackground = true) 429 | @Composable 430 | fun HistoryScreenPreview() { 431 | HistoryScreen() 432 | } 433 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/HomeScreen.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.ComponentName 5 | import android.content.Context 6 | import android.content.Intent 7 | import android.content.ServiceConnection 8 | import android.os.IBinder 9 | import android.widget.Toast 10 | import androidx.compose.foundation.background 11 | import androidx.compose.foundation.clickable 12 | import androidx.compose.foundation.layout.Arrangement 13 | import androidx.compose.foundation.layout.Box 14 | import androidx.compose.foundation.layout.Column 15 | import androidx.compose.foundation.layout.ExperimentalLayoutApi 16 | import androidx.compose.foundation.layout.FlowRow 17 | import androidx.compose.foundation.layout.PaddingValues 18 | import androidx.compose.foundation.layout.Row 19 | import androidx.compose.foundation.layout.Spacer 20 | import androidx.compose.foundation.layout.WindowInsets 21 | import androidx.compose.foundation.layout.WindowInsetsSides 22 | import androidx.compose.foundation.layout.fillMaxSize 23 | import androidx.compose.foundation.layout.fillMaxWidth 24 | import androidx.compose.foundation.layout.height 25 | import androidx.compose.foundation.layout.only 26 | import androidx.compose.foundation.layout.padding 27 | import androidx.compose.foundation.layout.safeDrawing 28 | import androidx.compose.foundation.layout.width 29 | import androidx.compose.foundation.layout.wrapContentHeight 30 | import androidx.compose.foundation.lazy.LazyColumn 31 | import androidx.compose.foundation.lazy.items 32 | import androidx.compose.foundation.rememberScrollState 33 | import androidx.compose.foundation.shape.RoundedCornerShape 34 | import androidx.compose.foundation.verticalScroll 35 | import androidx.compose.material3.AlertDialog 36 | import androidx.compose.material3.Button 37 | import androidx.compose.material3.CardDefaults 38 | import androidx.compose.material3.Checkbox 39 | import androidx.compose.material3.ExperimentalMaterial3Api 40 | import androidx.compose.material3.MaterialTheme 41 | import androidx.compose.material3.OutlinedCard 42 | import androidx.compose.material3.OutlinedTextField 43 | import androidx.compose.material3.RadioButton 44 | import androidx.compose.material3.RadioButtonDefaults 45 | import androidx.compose.material3.Scaffold 46 | import androidx.compose.material3.Slider 47 | import androidx.compose.material3.Text 48 | import androidx.compose.material3.TextButton 49 | import androidx.compose.material3.TopAppBar 50 | import androidx.compose.material3.TopAppBarDefaults 51 | import androidx.compose.material3.rememberTopAppBarState 52 | import androidx.compose.runtime.Composable 53 | import androidx.compose.runtime.DisposableEffect 54 | import androidx.compose.runtime.LaunchedEffect 55 | import androidx.compose.runtime.collectAsState 56 | import androidx.compose.runtime.getValue 57 | import androidx.compose.runtime.mutableFloatStateOf 58 | import androidx.compose.runtime.mutableIntStateOf 59 | import androidx.compose.runtime.mutableStateListOf 60 | import androidx.compose.runtime.mutableStateOf 61 | import androidx.compose.runtime.remember 62 | import androidx.compose.runtime.rememberCoroutineScope 63 | import androidx.compose.runtime.setValue 64 | import androidx.compose.ui.Alignment 65 | import androidx.compose.ui.Modifier 66 | import androidx.compose.ui.draw.clip 67 | import androidx.compose.ui.input.nestedscroll.nestedScroll 68 | import androidx.compose.ui.platform.LocalContext 69 | import androidx.compose.ui.tooling.preview.Preview 70 | import androidx.compose.ui.unit.dp 71 | import androidx.core.content.ContextCompat 72 | import kotlinx.coroutines.launch 73 | import me.neko.nzhelper.data.Session 74 | import me.neko.nzhelper.data.SessionRepository 75 | import me.neko.nzhelper.ui.service.TimerService 76 | import me.neko.nzhelper.ui.util.CalendarHeatMapStyled 77 | import me.neko.nzhelper.ui.util.buildDayStats 78 | import java.time.LocalDateTime 79 | 80 | @OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) 81 | @Composable 82 | fun HomeScreen() { 83 | val context = LocalContext.current 84 | val scope = rememberCoroutineScope() 85 | val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) 86 | 87 | // 绑定 Service 88 | val serviceIntent = remember { Intent(context, TimerService::class.java) } 89 | var timerService by remember { mutableStateOf(null) } 90 | val connection = remember { 91 | object : ServiceConnection { 92 | override fun onServiceConnected(name: ComponentName?, binder: IBinder?) { 93 | timerService = (binder as TimerService.LocalBinder).getService() 94 | } 95 | 96 | override fun onServiceDisconnected(name: ComponentName?) { 97 | timerService = null 98 | } 99 | } 100 | } 101 | 102 | // 启动并绑定服务 103 | LaunchedEffect(Unit) { 104 | ContextCompat.startForegroundService( 105 | context, 106 | serviceIntent.apply { action = TimerService.ACTION_START } 107 | ) 108 | context.bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE) 109 | } 110 | DisposableEffect(Unit) { 111 | onDispose { context.unbindService(connection) } 112 | } 113 | 114 | // 订阅 elapsedSec 115 | val elapsedSeconds by timerService 116 | ?.elapsedSec 117 | ?.collectAsState(initial = 0) 118 | ?: remember { mutableIntStateOf(0) } 119 | 120 | var isRunning by remember { mutableStateOf(false) } 121 | var showConfirmDialog by remember { mutableStateOf(false) } 122 | var showDetailsDialog by remember { mutableStateOf(false) } 123 | 124 | var showCalendar by remember { mutableStateOf(false) } 125 | 126 | var remarkInput by remember { mutableStateOf("") } 127 | var locationInput by remember { mutableStateOf("") } 128 | var watchedMovie by remember { mutableStateOf(false) } 129 | var climax by remember { mutableStateOf(false) } 130 | var rating by remember { mutableFloatStateOf(3f) } 131 | var mood by remember { mutableStateOf("平静") } 132 | var props by remember { mutableStateOf("手") } 133 | 134 | val sessions = remember { mutableStateListOf() } 135 | 136 | // 加载历史 137 | LaunchedEffect(Unit) { 138 | val loaded = SessionRepository.loadSessions(context) 139 | sessions.clear() 140 | sessions.addAll(loaded) 141 | } 142 | 143 | // 控制 Service 启停 144 | LaunchedEffect(isRunning) { 145 | val action = if (isRunning) TimerService.ACTION_START else TimerService.ACTION_PAUSE 146 | context.startService(serviceIntent.apply { this.action = action }) 147 | } 148 | 149 | Scaffold( 150 | topBar = { 151 | TopAppBar( 152 | title = { Text(text = "牛子小助手") }, 153 | scrollBehavior = scrollBehavior 154 | ) 155 | }, 156 | contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) 157 | ) { innerPadding -> 158 | Box( 159 | modifier = Modifier 160 | .fillMaxSize() 161 | .padding(innerPadding) 162 | .nestedScroll(scrollBehavior.nestedScrollConnection), 163 | contentAlignment = Alignment.Center // Box 控制 LazyColumn 居中 164 | ) { 165 | 166 | // 统计展示 167 | val totalCount = sessions.size 168 | val averageTimeMin = if (totalCount > 0) 169 | sessions.sumOf { it.duration }.toDouble() / totalCount / 60 170 | else 0.0 171 | val now = LocalDateTime.now() 172 | val weekCount = sessions.count { it.timestamp.isAfter(now.minusWeeks(1)) } 173 | val monthCount = sessions.count { it.timestamp.isAfter(now.minusMonths(1)) } 174 | val yearCount = sessions.count { it.timestamp.isAfter(now.minusYears(1)) } 175 | 176 | LazyColumn( 177 | modifier = Modifier 178 | .fillMaxWidth() 179 | .wrapContentHeight(), // 避免占满整个高度 180 | horizontalAlignment = Alignment.CenterHorizontally, 181 | verticalArrangement = Arrangement.spacedBy(16.dp), 182 | contentPadding = PaddingValues(bottom = 16.dp) 183 | ) { 184 | 185 | item { 186 | Column( 187 | horizontalAlignment = Alignment.CenterHorizontally, 188 | verticalArrangement = Arrangement.spacedBy(8.dp), 189 | modifier = Modifier 190 | .fillMaxWidth() 191 | .padding(top = 16.dp), 192 | ) { 193 | Text( 194 | text = "记录新的手艺活", 195 | style = MaterialTheme.typography.headlineMedium 196 | ) 197 | Text( 198 | text = "准备开始", 199 | style = MaterialTheme.typography.headlineLarge 200 | ) 201 | Text( 202 | text = formatTime(elapsedSeconds), 203 | style = MaterialTheme.typography.displayMedium 204 | ) 205 | 206 | Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) { 207 | Button(onClick = { 208 | isRunning = !isRunning 209 | }) { 210 | Text(if (isRunning) "暂停" else "开始") 211 | } 212 | Button(onClick = { 213 | if (elapsedSeconds > 0) showConfirmDialog = true 214 | else Toast.makeText(context, "计时尚未开始", Toast.LENGTH_SHORT) 215 | .show() 216 | }) { 217 | Text("结束") 218 | } 219 | } 220 | } 221 | } 222 | 223 | val stats = listOf( 224 | "总次数: $totalCount 次", 225 | "平均时间: ${"%.1f".format(averageTimeMin)} 分钟", 226 | "本周次数: $weekCount 次", 227 | "本月次数: $monthCount 次", 228 | "今年次数: $yearCount 次" 229 | ) 230 | items(stats) { info -> 231 | OutlinedCard( 232 | onClick = { 233 | showCalendar = true 234 | }, 235 | modifier = Modifier.fillMaxWidth(0.8f), 236 | border = CardDefaults.outlinedCardBorder() 237 | ) { 238 | Text( 239 | text = info, 240 | modifier = Modifier.padding(12.dp) 241 | ) 242 | } 243 | } 244 | } 245 | 246 | // 日历热力图 247 | if (showCalendar) { 248 | val dayStats = remember { buildDayStats(sessions) } 249 | AlertDialog( 250 | onDismissRequest = { showCalendar = false }, 251 | title = { Text(text = "发射日历") }, 252 | text = { 253 | Column( 254 | modifier = Modifier 255 | .fillMaxWidth() 256 | .padding(vertical = 8.dp) 257 | ) { 258 | CalendarHeatMapStyled(dayStats) 259 | } 260 | }, 261 | confirmButton = { 262 | TextButton(onClick = { showCalendar = false }) { 263 | Text("关闭") 264 | } 265 | } 266 | ) 267 | } 268 | 269 | // 结束对话框 270 | if (showConfirmDialog) { 271 | AlertDialog( 272 | onDismissRequest = { showConfirmDialog = false }, 273 | title = { Text("结束") }, 274 | text = { Text("要结束对牛牛的爱抚了吗?") }, 275 | confirmButton = { 276 | TextButton(onClick = { 277 | showConfirmDialog = false 278 | showDetailsDialog = true 279 | isRunning = false // 自动暂停计时 280 | }) { Text("燃尽了") } 281 | }, 282 | dismissButton = { 283 | TextButton(onClick = { showConfirmDialog = false }) { Text("再坚持一下") } 284 | } 285 | ) 286 | } 287 | 288 | // 使用 DetailsDialog 289 | DetailsDialog( 290 | show = showDetailsDialog, 291 | remark = remarkInput, 292 | onRemarkChange = { remarkInput = it }, 293 | location = locationInput, 294 | onLocationChange = { locationInput = it }, 295 | watchedMovie = watchedMovie, 296 | onWatchedMovieChange = { watchedMovie = it }, 297 | climax = climax, 298 | onClimaxChange = { climax = it }, 299 | props = props, 300 | onPropsChange = { props = it }, 301 | rating = rating, 302 | onRatingChange = { rating = it }, 303 | mood = mood, 304 | onMoodChange = { mood = it }, 305 | onConfirm = { 306 | val now = LocalDateTime.now() 307 | val session = Session( 308 | timestamp = now, 309 | duration = elapsedSeconds, 310 | remark = remarkInput, 311 | location = locationInput, 312 | watchedMovie = watchedMovie, 313 | climax = climax, 314 | rating = rating, 315 | mood = mood, 316 | props = props 317 | ) 318 | sessions.add(session) 319 | scope.launch { SessionRepository.saveSessions(context, sessions) } 320 | 321 | // 重置状态 322 | isRunning = false 323 | remarkInput = "" 324 | locationInput = "" 325 | watchedMovie = false 326 | climax = false 327 | rating = 3f 328 | mood = "平静" 329 | props = "手" 330 | showDetailsDialog = false 331 | 332 | // 停止服务 333 | context.startService( 334 | serviceIntent.apply { action = TimerService.ACTION_STOP } 335 | ) 336 | }, 337 | onDismiss = { showDetailsDialog = false } 338 | ) 339 | } 340 | } 341 | } 342 | 343 | @OptIn(ExperimentalLayoutApi::class) 344 | @Composable 345 | fun DetailsDialog( 346 | show: Boolean, 347 | remark: String, 348 | onRemarkChange: (String) -> Unit, 349 | location: String, 350 | onLocationChange: (String) -> Unit, 351 | watchedMovie: Boolean, 352 | onWatchedMovieChange: (Boolean) -> Unit, 353 | climax: Boolean, 354 | onClimaxChange: (Boolean) -> Unit, 355 | props: String, 356 | onPropsChange: (String) -> Unit, 357 | rating: Float, 358 | onRatingChange: (Float) -> Unit, 359 | mood: String, 360 | onMoodChange: (String) -> Unit, 361 | onConfirm: () -> Unit, 362 | onDismiss: () -> Unit 363 | ) { 364 | if (!show) return 365 | 366 | AlertDialog( 367 | onDismissRequest = onDismiss, 368 | title = { Text("填写本次信息") }, 369 | text = { 370 | val scrollState = rememberScrollState() 371 | Column( 372 | Modifier 373 | .fillMaxWidth() 374 | .verticalScroll(scrollState) 375 | ) { 376 | // 备注 377 | Text("备注(可选)") 378 | Spacer(Modifier.height(2.dp)) 379 | OutlinedTextField( 380 | value = remark, 381 | onValueChange = onRemarkChange, 382 | placeholder = { Text("有什么想说的?") }, 383 | modifier = Modifier.fillMaxWidth() 384 | ) 385 | Spacer(Modifier.height(12.dp)) 386 | 387 | // 起飞地点 388 | Text("起飞地点(可选)") 389 | Spacer(Modifier.height(2.dp)) 390 | OutlinedTextField( 391 | value = location, 392 | onValueChange = onLocationChange, 393 | placeholder = { Text("例如:卧室") }, 394 | modifier = Modifier.fillMaxWidth() 395 | ) 396 | Spacer(Modifier.height(12.dp)) 397 | 398 | // 选项:是否观看小电影 / 是否发射(高潮) 399 | Column { 400 | Row( 401 | verticalAlignment = Alignment.CenterVertically, 402 | modifier = Modifier 403 | .fillMaxWidth() 404 | .clickable { onWatchedMovieChange(!watchedMovie) } 405 | .padding(vertical = 8.dp) 406 | ) { 407 | Checkbox(checked = watchedMovie, onCheckedChange = null) 408 | Spacer(Modifier.width(4.dp)) 409 | Text("是否观看小电影") 410 | } 411 | 412 | Row( 413 | verticalAlignment = Alignment.CenterVertically, 414 | modifier = Modifier 415 | .fillMaxWidth() 416 | .clickable { onClimaxChange(!climax) } 417 | .padding(vertical = 8.dp) 418 | ) { 419 | Checkbox(checked = climax, onCheckedChange = null) 420 | Spacer(Modifier.width(4.dp)) 421 | Text("是否发射") 422 | } 423 | } 424 | 425 | Spacer(Modifier.height(12.dp)) 426 | 427 | // 道具 428 | Text( 429 | text = "道具:", 430 | modifier = Modifier.padding(bottom = 4.dp) 431 | ) 432 | 433 | val propList = listOf("手", "斐济杯", "小胶妻") 434 | FlowRow( 435 | modifier = Modifier.fillMaxWidth(), 436 | horizontalArrangement = Arrangement.spacedBy(8.dp), 437 | verticalArrangement = Arrangement.spacedBy(8.dp) 438 | ) { 439 | propList.forEach { p -> 440 | val isSelected = props == p 441 | 442 | Row( 443 | verticalAlignment = Alignment.CenterVertically, 444 | modifier = Modifier 445 | .clip(RoundedCornerShape(12.dp)) 446 | .background( 447 | if (isSelected) MaterialTheme.colorScheme.primaryContainer 448 | else MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.12f) 449 | ) 450 | .clickable { onPropsChange(p) } 451 | .padding(horizontal = 12.dp, vertical = 6.dp) 452 | ) { 453 | RadioButton( 454 | selected = isSelected, 455 | onClick = null, // 交由 Row 处理点击 456 | colors = RadioButtonDefaults.colors( 457 | selectedColor = MaterialTheme.colorScheme.primary, 458 | unselectedColor = MaterialTheme.colorScheme.onSurfaceVariant 459 | ) 460 | ) 461 | Spacer(Modifier.width(4.dp)) 462 | Text( 463 | text = p, 464 | color = if (isSelected) 465 | MaterialTheme.colorScheme.onPrimaryContainer 466 | else 467 | MaterialTheme.colorScheme.onSurface 468 | ) 469 | } 470 | } 471 | } 472 | Spacer(Modifier.height(12.dp)) 473 | 474 | // 评分 475 | Text("评分:${"%.1f".format(rating)}") 476 | Slider( 477 | value = rating, 478 | onValueChange = onRatingChange, 479 | valueRange = 0f..5f, 480 | steps = 25, 481 | modifier = Modifier.fillMaxWidth() 482 | ) 483 | Row( 484 | Modifier.fillMaxWidth(), 485 | horizontalArrangement = Arrangement.SpaceBetween 486 | ) { 487 | Text("0") 488 | Text("5.0") 489 | } 490 | Spacer(Modifier.height(12.dp)) 491 | 492 | // 心情 493 | Text( 494 | text = "心情:", 495 | modifier = Modifier.padding(bottom = 4.dp) 496 | ) 497 | 498 | val moods = listOf("平静", "愉悦", "兴奋", "疲惫", "这是最后一次!") 499 | FlowRow( 500 | modifier = Modifier.fillMaxWidth(), 501 | horizontalArrangement = Arrangement.spacedBy(8.dp), 502 | verticalArrangement = Arrangement.spacedBy(8.dp) 503 | ) { 504 | moods.forEach { m -> 505 | val isSelected = mood == m 506 | 507 | Row( 508 | verticalAlignment = Alignment.CenterVertically, 509 | modifier = Modifier 510 | .clip(RoundedCornerShape(12.dp)) 511 | .background( 512 | if (isSelected) MaterialTheme.colorScheme.primaryContainer 513 | else MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.12f) 514 | ) 515 | .clickable { onMoodChange(m) } 516 | .padding(horizontal = 12.dp, vertical = 6.dp) 517 | ) { 518 | RadioButton( 519 | selected = isSelected, 520 | onClick = null, 521 | colors = RadioButtonDefaults.colors( 522 | selectedColor = MaterialTheme.colorScheme.primary, 523 | unselectedColor = MaterialTheme.colorScheme.onSurfaceVariant 524 | ) 525 | ) 526 | Spacer(Modifier.width(4.dp)) 527 | Text( 528 | text = m, 529 | color = if (isSelected) 530 | MaterialTheme.colorScheme.onPrimaryContainer 531 | else 532 | MaterialTheme.colorScheme.onSurface 533 | ) 534 | } 535 | } 536 | } 537 | } 538 | }, 539 | confirmButton = { 540 | TextButton(onClick = onConfirm) { 541 | Text("确认") 542 | } 543 | }, 544 | dismissButton = { 545 | TextButton(onClick = onDismiss) { 546 | Text("取消") 547 | } 548 | } 549 | ) 550 | } 551 | 552 | @SuppressLint("DefaultLocale") 553 | private fun formatTime(totalSeconds: Int): String { 554 | val h = totalSeconds / 3600 555 | val m = (totalSeconds % 3600) / 60 556 | val s = totalSeconds % 60 557 | return buildString { 558 | if (h > 0) append(String.format("%02d:", h)) 559 | append(String.format("%02d:%02d", m, s)) 560 | } 561 | } 562 | 563 | @OptIn(ExperimentalMaterial3Api::class) 564 | @Preview(showBackground = true) 565 | @Composable 566 | fun HomeScreenPreview() { 567 | HomeScreen() 568 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/MainScreen.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.provider.Settings 6 | import androidx.compose.foundation.layout.WindowInsets 7 | import androidx.compose.foundation.layout.padding 8 | import androidx.compose.material3.AlertDialog 9 | import androidx.compose.material3.Button 10 | import androidx.compose.material3.ButtonDefaults 11 | import androidx.compose.material3.ExperimentalMaterial3Api 12 | import androidx.compose.material3.Icon 13 | import androidx.compose.material3.MaterialTheme 14 | import androidx.compose.material3.NavigationBar 15 | import androidx.compose.material3.NavigationBarItem 16 | import androidx.compose.material3.Scaffold 17 | import androidx.compose.material3.Text 18 | import androidx.compose.material3.TextButton 19 | import androidx.compose.runtime.Composable 20 | import androidx.compose.runtime.LaunchedEffect 21 | import androidx.compose.runtime.getValue 22 | import androidx.compose.runtime.mutableStateOf 23 | import androidx.compose.runtime.remember 24 | import androidx.compose.runtime.setValue 25 | import androidx.compose.ui.Modifier 26 | import androidx.compose.ui.platform.LocalContext 27 | import androidx.compose.ui.tooling.preview.Preview 28 | import androidx.core.app.NotificationManagerCompat 29 | import androidx.core.net.toUri 30 | import androidx.navigation.NavController 31 | import androidx.navigation.NavGraph.Companion.findStartDestination 32 | import androidx.navigation.compose.NavHost 33 | import androidx.navigation.compose.composable 34 | import androidx.navigation.compose.currentBackStackEntryAsState 35 | import androidx.navigation.compose.rememberNavController 36 | import me.neko.nzhelper.BuildConfig 37 | import me.neko.nzhelper.ui.util.BottomNavItem 38 | import me.neko.nzhelper.ui.util.UpdateChecker 39 | 40 | @Composable 41 | fun BottomNavigationBar(navController: NavController) { 42 | val navBackStackEntry by navController.currentBackStackEntryAsState() 43 | val currentRoute = navBackStackEntry?.destination?.route 44 | NavigationBar { 45 | BottomNavItem.Companion.items.forEach { item -> 46 | NavigationBarItem( 47 | icon = { Icon(imageVector = item.icon, contentDescription = item.title) }, 48 | label = { Text(text = item.title) }, 49 | selected = currentRoute == item.route, 50 | onClick = { 51 | navController.navigate(item.route) { 52 | launchSingleTop = true 53 | restoreState = true 54 | popUpTo(navController.graph.findStartDestination().id) { 55 | saveState = true 56 | } 57 | } 58 | } 59 | ) 60 | } 61 | } 62 | } 63 | 64 | @OptIn(ExperimentalMaterial3Api::class) 65 | @Composable 66 | fun MainScreen() { 67 | val navController = rememberNavController() 68 | val context = LocalContext.current 69 | 70 | // 检查通知权限 71 | val notificationsEnabled = NotificationManagerCompat.from(context).areNotificationsEnabled() 72 | var showNotifyDialog by remember { mutableStateOf(!notificationsEnabled) } 73 | 74 | // 打开应用通知设置 75 | fun openNotificationSettings(context: Context) { 76 | val intent = Intent().apply { 77 | action = 78 | Settings.ACTION_APP_NOTIFICATION_SETTINGS 79 | putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName) 80 | putExtra("app_uid", context.applicationInfo.uid) 81 | addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 82 | } 83 | context.startActivity(intent) 84 | } 85 | 86 | val owner = "bug-bit" 87 | val repo = "NzHelper" 88 | 89 | var showUpdateDialog by remember { mutableStateOf(false) } 90 | var latestTag by remember { mutableStateOf(null) } 91 | 92 | fun stripSuffix(version: String): String = 93 | version.trimStart('v', 'V').substringBefore('-') 94 | 95 | fun parseNumbers(version: String): List = 96 | stripSuffix(version) 97 | .split('.') 98 | .map { it.toIntOrNull() ?: 0 } 99 | .let { 100 | when { 101 | it.size >= 3 -> it.take(3) 102 | it.size == 2 -> it + listOf(0) 103 | it.size == 1 -> it + listOf(0, 0) 104 | else -> listOf(0, 0, 0) 105 | } 106 | } 107 | 108 | fun isRemoteGreater(local: String, remote: String): Boolean { 109 | val localNums = parseNumbers(local) 110 | val remoteNums = parseNumbers(remote) 111 | for (i in 0..2) { 112 | if (remoteNums[i] > localNums[i]) return true 113 | if (remoteNums[i] < localNums[i]) return false 114 | } 115 | return false 116 | } 117 | 118 | LaunchedEffect(Unit) { 119 | UpdateChecker.fetchLatestVersion(owner, repo)?.let { remoteVer -> 120 | latestTag = remoteVer 121 | if (isRemoteGreater(BuildConfig.VERSION_NAME, remoteVer)) { 122 | showUpdateDialog = true 123 | } 124 | } 125 | } 126 | 127 | Scaffold( 128 | bottomBar = { BottomNavigationBar(navController) }, 129 | contentWindowInsets = WindowInsets(0, 0, 0, 0) 130 | ) { innerPadding -> 131 | NavHost( 132 | navController = navController, 133 | startDestination = BottomNavItem.Home.route, 134 | modifier = Modifier.padding(innerPadding) 135 | ) { 136 | composable(BottomNavItem.Home.route) { HomeScreen() } 137 | composable(BottomNavItem.History.route) { HistoryScreen() } 138 | composable(BottomNavItem.Settings.route) { SettingsScreen(navController) } 139 | composable("about") { AboutScreen(navController) } 140 | composable("open_source") { OpenSourceScreen(navController) } 141 | } 142 | 143 | if (showUpdateDialog && latestTag != null) { 144 | AlertDialog( 145 | onDismissRequest = { showUpdateDialog = false }, 146 | title = { Text("检测到新版本") }, 147 | text = { 148 | Text( 149 | "当前版本:${BuildConfig.VERSION_NAME}\n" + 150 | "最新版本:$latestTag\n\n" + 151 | "针对你的牛牛进行了一些优化,是否前往 GitHub 下载?" 152 | ) 153 | }, 154 | confirmButton = { 155 | TextButton(onClick = { 156 | showUpdateDialog = false 157 | val intent = Intent( 158 | Intent.ACTION_VIEW, 159 | "https://github.com/$owner/$repo/releases/latest".toUri() 160 | ) 161 | context.startActivity(intent) 162 | }) { Text("去下载") } 163 | }, 164 | dismissButton = { 165 | TextButton(onClick = { showUpdateDialog = false }) { 166 | Text("稍后再说") 167 | } 168 | } 169 | ) 170 | } 171 | if (showNotifyDialog) { 172 | AlertDialog( 173 | onDismissRequest = { showNotifyDialog = false }, 174 | title = { 175 | Text(text = "还未开启通知权限") 176 | }, 177 | text = { 178 | Text("为确保应用能在后台继续计时,请授予通知权限!") 179 | }, 180 | confirmButton = { 181 | Button( 182 | onClick = { 183 | openNotificationSettings(context) 184 | showNotifyDialog = false 185 | }, 186 | colors = ButtonDefaults.buttonColors( 187 | containerColor = MaterialTheme.colorScheme.primary 188 | ) 189 | ) { 190 | Text("去开启") 191 | } 192 | }, 193 | dismissButton = { 194 | TextButton(onClick = { showNotifyDialog = false }) { 195 | Text("以后再说") 196 | } 197 | } 198 | ) 199 | } 200 | } 201 | } 202 | 203 | @OptIn(ExperimentalMaterial3Api::class) 204 | @Preview(showBackground = true) 205 | @Composable 206 | fun MainScreenPreview() { 207 | MainScreen() 208 | } 209 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/OpenSource.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import android.content.Intent 4 | import androidx.compose.foundation.clickable 5 | import androidx.compose.foundation.layout.Column 6 | import androidx.compose.foundation.layout.Row 7 | import androidx.compose.foundation.layout.WindowInsets 8 | import androidx.compose.foundation.layout.WindowInsetsSides 9 | import androidx.compose.foundation.layout.fillMaxSize 10 | import androidx.compose.foundation.layout.fillMaxWidth 11 | import androidx.compose.foundation.layout.only 12 | import androidx.compose.foundation.layout.padding 13 | import androidx.compose.foundation.layout.safeDrawing 14 | import androidx.compose.foundation.lazy.LazyColumn 15 | import androidx.compose.foundation.lazy.items 16 | import androidx.compose.material.icons.Icons 17 | import androidx.compose.material.icons.automirrored.filled.ArrowBack 18 | import androidx.compose.material3.ExperimentalMaterial3Api 19 | import androidx.compose.material3.Icon 20 | import androidx.compose.material3.IconButton 21 | import androidx.compose.material3.MaterialTheme 22 | import androidx.compose.material3.Scaffold 23 | import androidx.compose.material3.Text 24 | import androidx.compose.material3.TopAppBar 25 | import androidx.compose.material3.TopAppBarDefaults.pinnedScrollBehavior 26 | import androidx.compose.material3.rememberTopAppBarState 27 | import androidx.compose.runtime.Composable 28 | import androidx.compose.ui.Modifier 29 | import androidx.compose.ui.input.nestedscroll.nestedScroll 30 | import androidx.compose.ui.platform.LocalContext 31 | import androidx.compose.ui.text.style.TextDecoration 32 | import androidx.compose.ui.tooling.preview.Preview 33 | import androidx.compose.ui.unit.dp 34 | import androidx.navigation.NavHostController 35 | import androidx.navigation.compose.rememberNavController 36 | import androidx.core.net.toUri 37 | 38 | @OptIn(ExperimentalMaterial3Api::class) 39 | @Composable 40 | fun OpenSourceScreen( 41 | navController: NavHostController 42 | ) { 43 | val scrollBehavior = pinnedScrollBehavior(rememberTopAppBarState()) 44 | val context = LocalContext.current 45 | 46 | Scaffold( 47 | topBar = { 48 | TopAppBar( 49 | title = { Text("开放源代码") }, 50 | navigationIcon = { 51 | IconButton(onClick = { navController.popBackStack() }) { 52 | Icon( 53 | imageVector = Icons.AutoMirrored.Filled.ArrowBack, 54 | contentDescription = "返回" 55 | ) 56 | } 57 | }, 58 | scrollBehavior = scrollBehavior 59 | ) 60 | }, 61 | contentWindowInsets = WindowInsets.safeDrawing 62 | .only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) 63 | ) { innerPadding -> 64 | LazyColumn( 65 | modifier = Modifier 66 | .fillMaxSize() 67 | .padding(innerPadding) 68 | .nestedScroll(scrollBehavior.nestedScrollConnection) 69 | ) { 70 | items(licenseList) { item -> 71 | LicenseItemView(item) { 72 | val intent = Intent(Intent.ACTION_VIEW, item.url.toUri()) 73 | context.startActivity(intent) 74 | } 75 | } 76 | } 77 | } 78 | } 79 | 80 | @Composable 81 | fun LicenseItemView( 82 | item: LicenseItem, 83 | onClick: () -> Unit 84 | ) { 85 | Row( 86 | modifier = Modifier 87 | .fillMaxWidth() 88 | .clickable(onClick = onClick) 89 | ) { 90 | Column( 91 | modifier = Modifier 92 | .fillMaxWidth() 93 | .padding(horizontal = 24.dp, vertical = 16.dp) 94 | ) { 95 | Text(text = "${item.name} - ${item.author}", style = MaterialTheme.typography.bodyLarge) 96 | Text( 97 | text = item.url, 98 | style = MaterialTheme.typography.bodyMedium.copy( 99 | color = MaterialTheme.colorScheme.primary, 100 | textDecoration = TextDecoration.Underline 101 | ) 102 | ) 103 | Text(text = getLicense(item.type), style = MaterialTheme.typography.bodyMedium) 104 | } 105 | } 106 | } 107 | 108 | private val licenseList = listOf( 109 | LicenseItem( 110 | "Google", 111 | "Jetpack Compose", 112 | "https://github.com/androidx/androidx", 113 | LicenseType.Apache2 114 | ), 115 | LicenseItem( 116 | "JetBrains", 117 | "Kotlin", 118 | "https://github.com/JetBrains/kotlin", 119 | LicenseType.Apache2 120 | ), 121 | LicenseItem( 122 | "Google", 123 | "Material Design 3", 124 | "https://m3.material.io/", 125 | LicenseType.Apache2 126 | ), 127 | LicenseItem( 128 | "Google", 129 | "Gson", 130 | "https://github.com/google/gson", 131 | LicenseType.Apache2 132 | ), 133 | LicenseItem( 134 | "square", 135 | "Moshi", 136 | "https://github.com/square/moshi", 137 | LicenseType.Apache2 138 | ), 139 | LicenseItem( 140 | "square", 141 | "okhttp", 142 | "https://github.com/square/okhttp", 143 | LicenseType.Apache2 144 | ), 145 | ) 146 | 147 | data class LicenseItem( 148 | val author: String, 149 | val name: String, 150 | val url: String, 151 | val type: LicenseType 152 | ) 153 | 154 | enum class LicenseType { 155 | Apache2, 156 | MIT, 157 | GPL3 158 | } 159 | 160 | private fun getLicense(type: LicenseType): String = 161 | when (type) { 162 | LicenseType.Apache2 -> "Apache Software License 2.0" 163 | LicenseType.MIT -> "MIT License" 164 | LicenseType.GPL3 -> "GNU general public license Version 3" 165 | } 166 | 167 | @Preview(showBackground = true) 168 | @Composable 169 | fun OpenSourceScreenPreview() { 170 | OpenSourceScreen( 171 | navController = rememberNavController() 172 | ) 173 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/screens/SettingsScreen.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.screens 2 | 3 | import androidx.compose.foundation.clickable 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.Spacer 6 | import androidx.compose.foundation.layout.WindowInsets 7 | import androidx.compose.foundation.layout.WindowInsetsSides 8 | import androidx.compose.foundation.layout.fillMaxSize 9 | import androidx.compose.foundation.layout.fillMaxWidth 10 | import androidx.compose.foundation.layout.only 11 | import androidx.compose.foundation.layout.padding 12 | import androidx.compose.foundation.layout.safeDrawing 13 | import androidx.compose.material.icons.Icons 14 | import androidx.compose.material.icons.outlined.Info 15 | import androidx.compose.material3.ExperimentalMaterial3Api 16 | import androidx.compose.material3.Icon 17 | import androidx.compose.material3.ListItem 18 | import androidx.compose.material3.MaterialTheme 19 | import androidx.compose.material3.Scaffold 20 | import androidx.compose.material3.Text 21 | import androidx.compose.material3.TopAppBar 22 | import androidx.compose.material3.TopAppBarDefaults 23 | import androidx.compose.material3.rememberTopAppBarState 24 | import androidx.compose.runtime.Composable 25 | import androidx.compose.ui.Modifier 26 | import androidx.compose.ui.input.nestedscroll.nestedScroll 27 | import androidx.compose.ui.tooling.preview.Preview 28 | import androidx.navigation.NavController 29 | import androidx.navigation.compose.rememberNavController 30 | 31 | @OptIn(ExperimentalMaterial3Api::class) 32 | @Composable 33 | fun SettingsScreen( 34 | navController: NavController 35 | ) { 36 | val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) 37 | 38 | Scaffold( 39 | topBar = { 40 | TopAppBar( 41 | title = { Text("设置") }, 42 | scrollBehavior = scrollBehavior 43 | ) 44 | }, 45 | contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal) 46 | ) { innerPadding -> 47 | Column( 48 | modifier = Modifier 49 | .fillMaxSize() 50 | .padding(innerPadding) 51 | .nestedScroll(scrollBehavior.nestedScrollConnection) 52 | ) { 53 | ListItem( 54 | modifier = Modifier 55 | .fillMaxWidth() 56 | .clickable { 57 | navController.navigate("about") 58 | }, 59 | leadingContent = { 60 | Icon( 61 | imageVector = Icons.Outlined.Info, 62 | contentDescription = null, 63 | ) 64 | }, 65 | headlineContent = { 66 | Text(text = "关于", style = MaterialTheme.typography.titleMedium) 67 | } 68 | ) 69 | Spacer(modifier = Modifier.weight(1f)) 70 | } 71 | 72 | } 73 | } 74 | 75 | @Preview(showBackground = true) 76 | @Composable 77 | fun SettingsScreenPreview() { 78 | SettingsScreen( 79 | navController = rememberNavController() 80 | ) 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/service/TimerService.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.service 2 | 3 | import android.Manifest 4 | import android.app.Service 5 | import android.content.Intent 6 | import android.os.IBinder 7 | import android.os.Binder 8 | import android.os.Handler 9 | import android.os.Looper 10 | import android.app.Notification 11 | import android.annotation.SuppressLint 12 | import android.content.pm.ServiceInfo 13 | import android.os.Build 14 | import androidx.annotation.RequiresApi 15 | import androidx.annotation.RequiresPermission 16 | 17 | import androidx.core.app.NotificationCompat 18 | import androidx.core.app.NotificationManagerCompat 19 | 20 | import kotlinx.coroutines.flow.MutableStateFlow 21 | import kotlinx.coroutines.flow.StateFlow 22 | import kotlinx.coroutines.flow.asStateFlow 23 | import me.neko.nzhelper.R 24 | import me.neko.nzhelper.ui.util.NotificationUtil 25 | 26 | /** 27 | * 前台计时服务 28 | */ 29 | class TimerService : Service() { 30 | private val binder = LocalBinder() 31 | private val _elapsedSec = MutableStateFlow(0) 32 | val elapsedSec: StateFlow = _elapsedSec.asStateFlow() 33 | 34 | private var startTimeMs: Long = 0L 35 | private var accumulatedSec: Int = 0 36 | 37 | private val handler = Handler(Looper.getMainLooper()) 38 | private val tickRunnable = object : Runnable { 39 | @RequiresPermission(Manifest.permission.POST_NOTIFICATIONS) 40 | override fun run() { 41 | val nowMs = System.currentTimeMillis() 42 | _elapsedSec.value = accumulatedSec + ((nowMs - startTimeMs) / 1000).toInt() 43 | updateNotification(_elapsedSec.value) 44 | handler.postDelayed(this, 1000) 45 | } 46 | } 47 | 48 | override fun onBind(intent: Intent): IBinder = binder 49 | 50 | inner class LocalBinder : Binder() { 51 | fun getService(): TimerService = this@TimerService 52 | } 53 | 54 | @RequiresApi(Build.VERSION_CODES.Q) 55 | @SuppressLint("ForegroundServiceType") 56 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { 57 | when (intent?.action) { 58 | ACTION_START -> startTimer() 59 | ACTION_PAUSE -> pauseTimer() 60 | ACTION_STOP -> stopTimer() 61 | } 62 | return START_STICKY 63 | } 64 | 65 | /** 启动计时并进入前台 */ 66 | @RequiresApi(Build.VERSION_CODES.Q) 67 | private fun startTimer() { 68 | if (startTimeMs == 0L) { 69 | startTimeMs = System.currentTimeMillis() 70 | } 71 | handler.post(tickRunnable) 72 | val notif = buildNotification(_elapsedSec.value) 73 | // 以 dataSync 类型运行前台服务 74 | startForeground(NOTIF_ID, notif, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC) 75 | } 76 | 77 | /** 暂停计时(仍可保留通知) */ 78 | private fun pauseTimer() { 79 | handler.removeCallbacks(tickRunnable) 80 | accumulatedSec = _elapsedSec.value 81 | startTimeMs = 0L 82 | } 83 | 84 | /** 停止并重置计时 */ 85 | @Suppress("DEPRECATION") 86 | private fun stopTimer() { 87 | handler.removeCallbacks(tickRunnable) 88 | // 重置状态 89 | accumulatedSec = 0 90 | startTimeMs = 0L 91 | _elapsedSec.value = 0 92 | // 取消前台状态并移除通知 93 | stopForeground(true) 94 | stopSelf() 95 | } 96 | 97 | /** 构建通知 */ 98 | private fun buildNotification(elapsed: Int): Notification { 99 | val contentText = formatTime(elapsed) 100 | return NotificationCompat.Builder(this, NotificationUtil.CHANNEL_ID) 101 | .setContentTitle("计时进行中") 102 | .setContentText(contentText) 103 | .setSmallIcon(R.drawable.baseline_access_alarm_24) 104 | .setOnlyAlertOnce(true) 105 | .build() 106 | } 107 | 108 | @RequiresPermission(Manifest.permission.POST_NOTIFICATIONS) 109 | private fun updateNotification(elapsed: Int) { 110 | val notif = buildNotification(elapsed) 111 | NotificationManagerCompat.from(this).notify(NOTIF_ID, notif) 112 | } 113 | 114 | override fun onDestroy() { 115 | handler.removeCallbacks(tickRunnable) 116 | super.onDestroy() 117 | } 118 | 119 | companion object { 120 | const val ACTION_START = "me.neko.nzhelper.ACTION_START" 121 | const val ACTION_PAUSE = "me.neko.nzhelper.ACTION_PAUSE" 122 | const val ACTION_STOP = "me.neko.nzhelper.ACTION_STOP" 123 | const val NOTIF_ID = 1001 124 | } 125 | 126 | @SuppressLint("DefaultLocale") 127 | private fun formatTime(totalSeconds: Int): String { 128 | val h = totalSeconds / 3600 129 | val m = (totalSeconds % 3600) / 60 130 | val s = totalSeconds % 60 131 | return buildString { 132 | if (h > 0) append(String.format("%02d:", h)) 133 | append(String.format("%02d:%02d", m, s)) 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple80 = Color(0xFFD0BCFF) 6 | val PurpleGrey80 = Color(0xFFCCC2DC) 7 | val Pink80 = Color(0xFFEFB8C8) 8 | 9 | val Purple40 = Color(0xFF6650a4) 10 | val PurpleGrey40 = Color(0xFF625b71) 11 | val Pink40 = Color(0xFF7D5260) -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.theme 2 | 3 | import android.app.Activity 4 | import android.os.Build 5 | import androidx.compose.foundation.isSystemInDarkTheme 6 | import androidx.compose.material3.MaterialTheme 7 | import androidx.compose.material3.darkColorScheme 8 | import androidx.compose.material3.dynamicDarkColorScheme 9 | import androidx.compose.material3.dynamicLightColorScheme 10 | import androidx.compose.material3.lightColorScheme 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.ui.platform.LocalContext 13 | 14 | private val DarkColorScheme = darkColorScheme( 15 | primary = Purple80, 16 | secondary = PurpleGrey80, 17 | tertiary = Pink80 18 | ) 19 | 20 | private val LightColorScheme = lightColorScheme( 21 | primary = Purple40, 22 | secondary = PurpleGrey40, 23 | tertiary = Pink40 24 | 25 | /* Other default colors to override 26 | background = Color(0xFFFFFBFE), 27 | surface = Color(0xFFFFFBFE), 28 | onPrimary = Color.White, 29 | onSecondary = Color.White, 30 | onTertiary = Color.White, 31 | onBackground = Color(0xFF1C1B1F), 32 | onSurface = Color(0xFF1C1B1F), 33 | */ 34 | ) 35 | 36 | @Composable 37 | fun NzHelperTheme( 38 | darkTheme: Boolean = isSystemInDarkTheme(), 39 | // Dynamic color is available on Android 12+ 40 | dynamicColor: Boolean = true, 41 | content: @Composable () -> Unit 42 | ) { 43 | val colorScheme = when { 44 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 45 | val context = LocalContext.current 46 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 47 | } 48 | 49 | darkTheme -> DarkColorScheme 50 | else -> LightColorScheme 51 | } 52 | 53 | MaterialTheme( 54 | colorScheme = colorScheme, 55 | typography = Typography, 56 | content = content 57 | ) 58 | } -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.theme 2 | 3 | import androidx.compose.material3.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/util/BottomNavItem.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.util 2 | 3 | import androidx.compose.material.icons.Icons 4 | import androidx.compose.material.icons.automirrored.filled.List 5 | import androidx.compose.material.icons.filled.Home 6 | import androidx.compose.material.icons.filled.Settings 7 | import androidx.compose.ui.graphics.vector.ImageVector 8 | 9 | sealed class BottomNavItem( 10 | val route: String, 11 | val title: String, 12 | val icon: ImageVector 13 | ) { 14 | object Home : BottomNavItem( 15 | route = "home", 16 | title = "首页", 17 | icon = Icons.Default.Home 18 | ) 19 | 20 | object History : BottomNavItem( 21 | route = "history", 22 | title = "历史", 23 | icon = Icons.AutoMirrored.Filled.List 24 | ) 25 | 26 | object Settings : BottomNavItem( 27 | route = "settings", 28 | title = "设置", 29 | icon = Icons.Default.Settings 30 | ) 31 | 32 | companion object { 33 | val items = listOf(Home, History, Settings) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/util/CalendarHeatMap.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.util 2 | 3 | import androidx.compose.animation.animateColorAsState 4 | import androidx.compose.foundation.background 5 | import androidx.compose.foundation.border 6 | import androidx.compose.foundation.gestures.detectTapGestures 7 | import androidx.compose.foundation.horizontalScroll 8 | import androidx.compose.foundation.layout.Arrangement 9 | import androidx.compose.foundation.layout.Box 10 | import androidx.compose.foundation.layout.Column 11 | import androidx.compose.foundation.layout.Row 12 | import androidx.compose.foundation.layout.Spacer 13 | import androidx.compose.foundation.layout.height 14 | import androidx.compose.foundation.layout.padding 15 | import androidx.compose.foundation.layout.size 16 | import androidx.compose.foundation.layout.width 17 | import androidx.compose.foundation.rememberScrollState 18 | import androidx.compose.foundation.shape.RoundedCornerShape 19 | import androidx.compose.material3.Card 20 | import androidx.compose.material3.CardDefaults 21 | import androidx.compose.material3.MaterialTheme 22 | import androidx.compose.material3.Text 23 | import androidx.compose.runtime.Composable 24 | import androidx.compose.runtime.LaunchedEffect 25 | import androidx.compose.runtime.getValue 26 | import androidx.compose.runtime.mutableStateOf 27 | import androidx.compose.runtime.remember 28 | import androidx.compose.runtime.setValue 29 | import androidx.compose.ui.Alignment 30 | import androidx.compose.ui.Modifier 31 | import androidx.compose.ui.draw.clip 32 | import androidx.compose.ui.graphics.Color 33 | import androidx.compose.ui.input.pointer.pointerInput 34 | import androidx.compose.ui.text.style.TextAlign 35 | import androidx.compose.ui.unit.Dp 36 | import androidx.compose.ui.unit.dp 37 | import androidx.compose.ui.window.Popup 38 | import me.neko.nzhelper.data.Session 39 | import java.time.DayOfWeek 40 | import java.time.LocalDate 41 | import java.time.format.DateTimeFormatter 42 | import java.time.temporal.ChronoUnit 43 | 44 | data class DayStat(val date: LocalDate, val count: Int) 45 | 46 | // 根据首次记录和当前日期动态生成范围 47 | fun buildDayStats( 48 | sessions: List, 49 | daysBefore: Long = 10, 50 | daysAfter: Long = 30 51 | ): List { 52 | val today = LocalDate.now() 53 | // 首次记录日期 54 | val firstDate = sessions.minOfOrNull { it.timestamp.toLocalDate() } ?: today 55 | // 范围起止 56 | val start = firstDate.minusDays(daysBefore) 57 | val end = today.plusDays(daysAfter) 58 | val totalDays = ChronoUnit.DAYS.between(start, end).toInt() 59 | // 汇总 60 | val map = sessions.groupingBy { it.timestamp.toLocalDate() }.eachCount() 61 | return (0..totalDays).map { offset -> 62 | val date = start.plusDays(offset.toLong()) 63 | DayStat(date, map[date] ?: 0) 64 | } 65 | } 66 | 67 | @Composable 68 | fun CalendarHeatMapStyled( 69 | dayStats: List, 70 | modifier: Modifier = Modifier, 71 | cellSize: Dp = 20.dp, 72 | cellSpacing: Dp = 4.dp, 73 | // 高对比度色板:0次灰白,1-4次不同警示色,>=5次深警示红 74 | colors: List = listOf( 75 | MaterialTheme.colorScheme.surfaceVariant, // 0 次 76 | Color(0xFFFFF59D), // 1 次 77 | Color(0xFFFFC107), // 2 次 78 | Color(0xFFFF5722), // 3 次 79 | Color(0xFFF44336), // 4 次 80 | MaterialTheme.colorScheme.error // >=5 次 81 | ), 82 | showCountInCell: Boolean = false, 83 | weekDayLabels: List = listOf("一", "二", "三", "四", "五", "六", "日"), 84 | monthLabels: List = listOf( 85 | "一月", "二月", "三月", "四月", "五月", "六月", 86 | "七月", "八月", "九月", "十月", "十一月", "十二月" 87 | ) 88 | ) { 89 | val today = LocalDate.now() 90 | val firstRecordDate = dayStats.minOfOrNull { it.date } ?: today 91 | // 显示范围:从首条记录前10天 到 今天后30天 92 | val startDate = firstRecordDate.minusDays(10) 93 | val endDate = today.plusDays(30) 94 | 95 | // 对齐到周一开始 96 | val daysToSubtract = (startDate.dayOfWeek.value - DayOfWeek.MONDAY.value).toLong() 97 | val alignedStart = if (daysToSubtract > 0) startDate.minusDays(daysToSubtract) else startDate 98 | // 不再填充到周日,末尾使用精确 endDate 99 | val alignedEnd = endDate 100 | 101 | val totalDays = ChronoUnit.DAYS.between(alignedStart, alignedEnd).toInt() 102 | // 构建完整日期列表 103 | val dateList = remember(alignedStart, alignedEnd) { 104 | (0..totalDays).map { alignedStart.plusDays(it.toLong()) } 105 | } 106 | // 统计映射 107 | val statsMap = remember(dayStats) { dayStats.associateBy { it.date } } 108 | val fullStats = remember(dateList, statsMap) { 109 | dateList.map { date -> DayStat(date, statsMap[date]?.count ?: 0) } 110 | } 111 | // 按周分组,每周最多7天,最后一周可能不足7天 112 | val weeks = remember(fullStats) { fullStats.chunked(7) } 113 | var tooltipData by remember { mutableStateOf(null) } 114 | val scrollState = rememberScrollState() 115 | LaunchedEffect(Unit) { 116 | // 滚动到最新的列(即末尾) 117 | scrollState.scrollTo(scrollState.maxValue) 118 | } 119 | 120 | Column(modifier) { 121 | // 月份标签,与热力图一起滚动 122 | Row( 123 | Modifier 124 | .horizontalScroll(scrollState) 125 | .padding(start = cellSize + cellSpacing) 126 | ) { 127 | var lastMonth = 0 128 | weeks.forEach { week -> 129 | val month = week.first().date.monthValue 130 | if (month != lastMonth) { 131 | Text( 132 | text = monthLabels[month - 1], 133 | style = MaterialTheme.typography.bodySmall, 134 | modifier = Modifier.width(cellSize + cellSpacing), 135 | textAlign = TextAlign.Center 136 | ) 137 | lastMonth = month 138 | } else { 139 | Spacer(Modifier.width(cellSize + cellSpacing)) 140 | } 141 | } 142 | } 143 | Row { 144 | // 星期标签 145 | Column( 146 | verticalArrangement = Arrangement.spacedBy(cellSpacing), 147 | modifier = Modifier.padding(end = 4.dp) 148 | ) { 149 | weekDayLabels.forEach { wd -> 150 | Text(wd, style = MaterialTheme.typography.bodySmall) 151 | Spacer(Modifier.height(cellSpacing - 2.dp)) 152 | } 153 | } 154 | // 热力图网格 155 | Row( 156 | Modifier 157 | .horizontalScroll(scrollState) 158 | .padding(horizontal = 8.dp, vertical = 8.dp), 159 | horizontalArrangement = Arrangement.spacedBy(cellSpacing) 160 | ) { 161 | weeks.forEach { week -> 162 | Column(verticalArrangement = Arrangement.spacedBy(cellSpacing)) { 163 | week.forEach { ds -> 164 | val level = ds.count.coerceAtMost(5) 165 | val bgColor by animateColorAsState(colors[level]) 166 | Box( 167 | contentAlignment = Alignment.Center, 168 | modifier = Modifier 169 | .size(cellSize) 170 | .clip(RoundedCornerShape(4.dp)) 171 | .background(bgColor) 172 | .border( 173 | 1.dp, 174 | MaterialTheme.colorScheme.onSurfaceVariant, 175 | RoundedCornerShape(4.dp) 176 | ) 177 | .pointerInput(ds) { 178 | detectTapGestures(onLongPress = { tooltipData = ds }) 179 | } 180 | ) { 181 | if (showCountInCell && ds.count > 0) { 182 | Text( 183 | text = ds.count.toString(), 184 | style = MaterialTheme.typography.bodySmall, 185 | color = MaterialTheme.colorScheme.onPrimaryContainer, 186 | maxLines = 1 187 | ) 188 | } 189 | } 190 | } 191 | } 192 | } 193 | } 194 | } 195 | // Tooltip 196 | tooltipData?.let { ds -> 197 | Popup( 198 | alignment = Alignment.Center, 199 | onDismissRequest = { tooltipData = null } 200 | ) { 201 | Card( 202 | shape = RoundedCornerShape(8.dp), 203 | elevation = CardDefaults.cardElevation(defaultElevation = 6.dp), 204 | modifier = Modifier.padding(8.dp) 205 | ) { 206 | Column(modifier = Modifier.padding(12.dp)) { 207 | Text( 208 | ds.date.format(DateTimeFormatter.ISO_DATE), 209 | style = MaterialTheme.typography.bodyMedium 210 | ) 211 | Spacer(Modifier.height(4.dp)) 212 | Text("${ds.count} 次", style = MaterialTheme.typography.bodySmall) 213 | } 214 | } 215 | } 216 | } 217 | Spacer(Modifier.height(8.dp)) 218 | // 图例 219 | Row( 220 | horizontalArrangement = Arrangement.spacedBy(8.dp), 221 | verticalAlignment = Alignment.CenterVertically, 222 | modifier = Modifier.align(Alignment.CenterHorizontally) 223 | ) { 224 | Text("少", style = MaterialTheme.typography.bodySmall) 225 | colors.forEach { 226 | Box(Modifier 227 | .size(cellSize) 228 | .background(it, RoundedCornerShape(4.dp))) 229 | } 230 | Text("多", style = MaterialTheme.typography.bodySmall) 231 | } 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/util/GitHubRelease.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.util 2 | 3 | import android.util.Log 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.Moshi 6 | import kotlinx.coroutines.Dispatchers 7 | import kotlinx.coroutines.withContext 8 | import okhttp3.OkHttpClient 9 | import okhttp3.Request 10 | 11 | data class GitHubRelease( 12 | @param:Json(name = "tag_name") val tagName: String, 13 | @param:Json(name = "name") val releaseName: String 14 | ) 15 | 16 | object UpdateChecker { 17 | private val client = OkHttpClient() 18 | private val moshi = Moshi.Builder() 19 | .add(com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory()) 20 | .build() 21 | private val adapter = moshi.adapter(GitHubRelease::class.java) 22 | 23 | suspend fun fetchLatestVersion(owner: String, repo: String): String? = 24 | withContext(Dispatchers.IO) { 25 | try { 26 | val resp = client.newCall( 27 | Request.Builder() 28 | .url("https://api.github.com/repos/$owner/$repo/releases/latest") 29 | .header("User-Agent", "MyApp/1.0") // 避免 403 30 | .build() 31 | ).execute() 32 | 33 | if (!resp.isSuccessful) return@withContext null 34 | 35 | val body = resp.body.string().also { 36 | Log.d("UpdateCheck", "GitHub raw JSON: $it") 37 | } 38 | 39 | adapter.fromJson(body)?.releaseName 40 | } catch (e: Exception) { 41 | Log.e("UpdateCheck", "Error checking update", e) 42 | null 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/me/neko/nzhelper/ui/util/NotificationUtil.kt: -------------------------------------------------------------------------------- 1 | package me.neko.nzhelper.ui.util 2 | 3 | import android.app.NotificationChannel 4 | import android.app.NotificationManager 5 | import android.content.Context 6 | 7 | object NotificationUtil { 8 | const val CHANNEL_ID = "timer_channel" 9 | const val CHANNEL_NAME = "计时服务" 10 | 11 | fun createChannel(context: Context) { 12 | val chan = NotificationChannel( 13 | CHANNEL_ID, 14 | CHANNEL_NAME, 15 | NotificationManager.IMPORTANCE_LOW 16 | ).apply { 17 | setShowBadge(false) 18 | } 19 | context.getSystemService(NotificationManager::class.java) 20 | .createNotificationChannel(chan) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_access_alarm_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/code_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/source_code_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bug-bit/NzHelper/abb5bc33ccbd9322c4623406f1c2ad4d07310b9b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |