Skip to content

Commit 03291c9

Browse files
committed
开启R8,优化弹层UI
1 parent 8bded9c commit 03291c9

8 files changed

Lines changed: 56 additions & 70 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ google-services.json
3939
.AppleDouble
4040
.LSOverride
4141

42-
.report/
42+
.signing/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Chronos
22

3-
> Chronos 是一个简单的课程表应用,仅支持查看、编辑和分享课表功能
3+
> Chronos 是一个简单的 Android 课程表应用,仅支持查看和分享课表
44
55
<p align="center">
66
<img src="assets/Screenshot_1.png" alt="Screenshot 2" width="48%" />

app/build.gradle.kts

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import java.util.Locale
3+
import java.util.Properties
34

45
plugins {
56
alias(libs.plugins.android.application)
@@ -8,20 +9,45 @@ plugins {
89
alias(libs.plugins.ksp)
910
}
1011

11-
val releaseStoreFile = providers.gradleProperty("RELEASE_STORE_FILE")
12-
val releaseStorePassword = providers.gradleProperty("RELEASE_STORE_PASSWORD")
13-
val releaseKeyAlias = providers.gradleProperty("RELEASE_KEY_ALIAS")
14-
val releaseKeyPassword = providers.gradleProperty("RELEASE_KEY_PASSWORD")
12+
val localSigningProperties = Properties().apply {
13+
val localSigningFile = rootProject.file(".signing/.env.release-signing")
14+
if (localSigningFile.isFile) {
15+
localSigningFile.inputStream().use(::load)
16+
}
17+
}
18+
19+
fun resolveStoreFile(): String? {
20+
val localStoreFile = localSigningProperties.getProperty("RELEASE_STORE_FILE")
21+
if (!localStoreFile.isNullOrBlank() && rootProject.file(localStoreFile).isFile) {
22+
return localStoreFile
23+
}
24+
25+
val configuredPath = providers.gradleProperty("RELEASE_STORE_FILE").orNull
26+
if (!configuredPath.isNullOrBlank() && rootProject.file(configuredPath).isFile) {
27+
return configuredPath
28+
}
29+
30+
return null
31+
}
32+
33+
fun resolveSigningProperty(name: String): String? =
34+
localSigningProperties.getProperty(name)?.takeIf { it.isNotBlank() }
35+
?: providers.gradleProperty(name).orNull
36+
37+
val releaseStoreFile = resolveStoreFile()
38+
val releaseStorePassword = resolveSigningProperty("RELEASE_STORE_PASSWORD")
39+
val releaseKeyAlias = resolveSigningProperty("RELEASE_KEY_ALIAS")
40+
val releaseKeyPassword = resolveSigningProperty("RELEASE_KEY_PASSWORD")
1541
val appVersionName = providers.gradleProperty("APP_VERSION").orElse("1.0.0")
1642
val releaseAbiNames = mapOf(
1743
"arm64-v8a" to "v8a",
1844
"armeabi-v7a" to "v7a",
1945
"x86_64" to "x86_64",
2046
)
21-
val hasReleaseSigning = releaseStoreFile.isPresent &&
22-
releaseStorePassword.isPresent &&
23-
releaseKeyAlias.isPresent &&
24-
releaseKeyPassword.isPresent
47+
val hasReleaseSigning = !releaseStoreFile.isNullOrBlank() &&
48+
!releaseStorePassword.isNullOrBlank() &&
49+
!releaseKeyAlias.isNullOrBlank() &&
50+
!releaseKeyPassword.isNullOrBlank()
2551

2652
android {
2753
namespace = "com.chronos.mobile"
@@ -43,17 +69,18 @@ android {
4369
signingConfigs {
4470
if (hasReleaseSigning) {
4571
create("release") {
46-
storeFile = rootProject.file(releaseStoreFile.get())
47-
storePassword = releaseStorePassword.get()
48-
keyAlias = releaseKeyAlias.get()
49-
keyPassword = releaseKeyPassword.get()
72+
storeFile = rootProject.file(requireNotNull(releaseStoreFile))
73+
storePassword = requireNotNull(releaseStorePassword)
74+
keyAlias = requireNotNull(releaseKeyAlias)
75+
keyPassword = requireNotNull(releaseKeyPassword)
5076
}
5177
}
5278
}
5379

5480
buildTypes {
5581
release {
56-
isMinifyEnabled = false
82+
isMinifyEnabled = true
83+
isShrinkResources = true
5784
if (hasReleaseSigning) {
5885
signingConfig = signingConfigs.getByName("release")
5986
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<string name="app_name">Chronos 课表</string>
3+
<string name="app_name">Chronos</string>
44
</resources>

feature/timetable/src/main/java/com/chronos/mobile/feature/timetable/ManageTimetablesDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal fun ManageTimetablesDialog(
5353
confirmButton = {},
5454
title = {
5555
Row(verticalAlignment = Alignment.CenterVertically) {
56-
BrandedDialogTitle(
56+
DialogTitleBlock(
5757
title = stringResource(R.string.timetable_manage_title),
5858
subtitle = stringResource(R.string.timetable_manage_subtitle),
5959
modifier = Modifier.weight(1f),

feature/timetable/src/main/java/com/chronos/mobile/feature/timetable/TimetableComponents.kt

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
package com.chronos.mobile.feature.timetable
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.border
54
import androidx.compose.foundation.layout.Arrangement
6-
import androidx.compose.foundation.layout.Box
75
import androidx.compose.foundation.layout.Row
86
import androidx.compose.foundation.layout.Spacer
97
import androidx.compose.foundation.layout.fillMaxWidth
108
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.foundation.layout.size
129
import androidx.compose.foundation.layout.width
1310
import androidx.compose.foundation.shape.RoundedCornerShape
1411
import androidx.compose.material3.MaterialTheme
1512
import androidx.compose.material3.OutlinedButton
1613
import androidx.compose.material3.OutlinedTextField
17-
import androidx.compose.material3.Surface
1814
import androidx.compose.material3.Switch
1915
import androidx.compose.material3.Text
2016
import androidx.compose.material3.TextButton
2117
import androidx.compose.runtime.Composable
2218
import androidx.compose.ui.Alignment
2319
import androidx.compose.ui.Modifier
24-
import androidx.compose.ui.res.painterResource
2520
import androidx.compose.ui.res.stringResource
2621
import androidx.compose.ui.text.style.TextAlign
2722
import androidx.compose.ui.unit.dp
@@ -118,37 +113,18 @@ internal fun PeriodStepperRow(
118113
}
119114

120115
@Composable
121-
internal fun BrandedDialogTitle(
116+
internal fun DialogTitleBlock(
122117
title: String,
123118
subtitle: String,
124119
modifier: Modifier = Modifier,
125120
) {
126-
Row(
127-
modifier = modifier,
128-
verticalAlignment = Alignment.CenterVertically,
129-
) {
130-
Surface(
131-
modifier = Modifier.size(40.dp),
132-
shape = RoundedCornerShape(14.dp),
133-
color = MaterialTheme.colorScheme.primaryContainer,
134-
) {
135-
Box(contentAlignment = Alignment.Center) {
136-
Image(
137-
painter = painterResource(id = R.drawable.ic_brand_mark),
138-
contentDescription = null,
139-
modifier = Modifier.size(24.dp),
140-
)
141-
}
142-
}
143-
Spacer(modifier = Modifier.width(12.dp))
144-
androidx.compose.foundation.layout.Column {
145-
Text(text = title, style = MaterialTheme.typography.titleLarge)
146-
Text(
147-
text = subtitle,
148-
style = MaterialTheme.typography.bodySmall,
149-
color = MaterialTheme.colorScheme.onSurfaceVariant,
150-
)
151-
}
121+
androidx.compose.foundation.layout.Column(modifier = modifier) {
122+
Text(text = title, style = MaterialTheme.typography.titleLarge)
123+
Text(
124+
text = subtitle,
125+
style = MaterialTheme.typography.bodySmall,
126+
color = MaterialTheme.colorScheme.onSurfaceVariant,
127+
)
152128
}
153129
}
154130

feature/timetable/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<string name="timetable_manage_action">管理课程表</string>
1212

1313
<string name="timetable_manage_title">管理课程表</string>
14-
<string name="timetable_manage_subtitle">切换、新建或整理你的本地课表</string>
14+
<string name="timetable_manage_subtitle">新建或切换本地课表</string>
1515
<string name="timetable_create_action">新建课程表</string>
1616
<string name="timetable_course_count">%1$d 门课程</string>
1717

feature/transfer/src/main/java/com/chronos/mobile/feature/transfer/TransferDialogHost.kt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import androidx.activity.result.contract.ActivityResultContracts
77
import androidx.compose.foundation.BorderStroke
88
import androidx.compose.foundation.clickable
99
import androidx.compose.foundation.layout.Arrangement
10-
import androidx.compose.foundation.layout.Box
1110
import androidx.compose.foundation.layout.Column
1211
import androidx.compose.foundation.layout.Row
1312
import androidx.compose.foundation.layout.Spacer
1413
import androidx.compose.foundation.layout.fillMaxWidth
1514
import androidx.compose.foundation.layout.padding
1615
import androidx.compose.foundation.layout.size
17-
import androidx.compose.foundation.shape.CircleShape
1816
import androidx.compose.foundation.shape.RoundedCornerShape
1917
import androidx.compose.material.icons.Icons
2018
import androidx.compose.material.icons.filled.IosShare
@@ -217,22 +215,8 @@ private fun TransferDialog(
217215
text = {
218216
if (mode == TransferDialogMode.EXPORT) {
219217
Column(horizontalAlignment = Alignment.CenterHorizontally) {
220-
Surface(
221-
modifier = Modifier.size(64.dp),
222-
shape = CircleShape,
223-
color = MaterialTheme.colorScheme.primaryContainer,
224-
) {
225-
Box(contentAlignment = Alignment.Center) {
226-
Icon(
227-
imageVector = Icons.Default.IosShare,
228-
contentDescription = null,
229-
tint = MaterialTheme.colorScheme.onPrimaryContainer,
230-
)
231-
}
232-
}
233-
Spacer(modifier = Modifier.size(16.dp))
234218
Text(
235-
text = "将“${currentTimetableName ?: "未命名"}”复制到剪贴板,包含学期第一天等完整课表信息",
219+
text = "将“${currentTimetableName ?: "未命名"}”复制到剪贴板,复制后包含完整课表设置信息",
236220
color = MaterialTheme.colorScheme.onSurfaceVariant,
237221
)
238222
Spacer(modifier = Modifier.size(16.dp))
@@ -327,15 +311,14 @@ private fun ImportModeRow(
327311
modifier = Modifier
328312
.fillMaxWidth()
329313
.clip(RoundedCornerShape(18.dp))
330-
.clickable(enabled = enabled, onClick = onClick)
331-
.padding(12.dp),
314+
.clickable(enabled = enabled, onClick = onClick),
332315
shape = RoundedCornerShape(18.dp),
333316
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),
334317
) {
335318
Row(
336319
modifier = Modifier
337320
.fillMaxWidth()
338-
.padding(horizontal = 12.dp, vertical = 4.dp),
321+
.padding(horizontal = 24.dp, vertical = 16.dp),
339322
verticalAlignment = Alignment.CenterVertically,
340323
) {
341324
RadioButton(selected = selected, onClick = null, enabled = enabled)

0 commit comments

Comments
 (0)