Refactor string resources: rename and reorganize

- Rename error strings to use error_ prefix consistently
- Rename success strings to use success_ prefix
- Rename failure strings to use failed_ prefix
- Reorganize strings by feature groups with section comments
- Remove unused shortcuts.xml and manifest references
- Update all Kotlin code references
This commit is contained in:
世界
2025-12-30 19:24:10 +08:00
parent be1f6a2711
commit 9dea064353
13 changed files with 525 additions and 453 deletions

View File

@@ -1098,17 +1098,17 @@ class MainActivity : ComponentActivity(), ServiceConnection.Callback {
val title =
when (alertType) {
Alert.RequestNotificationPermission -> stringResource(R.string.notification_permission_title)
Alert.StartCommandServer -> stringResource(R.string.service_error_title_start_command_server)
Alert.CreateService -> stringResource(R.string.service_error_title_create_service)
Alert.StartService -> stringResource(R.string.service_error_title_start_service)
Alert.StartCommandServer -> stringResource(R.string.error_start_command_server)
Alert.CreateService -> stringResource(R.string.error_create_service)
Alert.StartService -> stringResource(R.string.error_start_service)
else -> null
}
val dialogMessage =
when (alertType) {
Alert.RequestVPNPermission -> stringResource(R.string.service_error_missing_permission)
Alert.RequestVPNPermission -> stringResource(R.string.error_missing_vpn_permission)
Alert.RequestNotificationPermission -> stringResource(R.string.notification_permission_required_description)
Alert.EmptyConfiguration -> stringResource(R.string.service_error_empty_configuration)
Alert.EmptyConfiguration -> stringResource(R.string.error_empty_configuration)
else -> message
}

View File

@@ -59,7 +59,7 @@ fun DashboardScreen(
val note = uiState.deprecatedNotes.first()
AlertDialog(
onDismissRequest = { },
title = { Text(stringResource(R.string.service_error_title_deprecated_warning)) },
title = { Text(stringResource(R.string.error_deprecated_warning)) },
text = { Text(note.message) },
confirmButton = {
TextButton(onClick = { viewModel.dismissDeprecatedNote() }) {
@@ -73,7 +73,7 @@ fun DashboardScreen(
viewModel.sendGlobalEvent(UiEvent.OpenUrl(note.migrationLink))
viewModel.dismissDeprecatedNote()
}) {
Text(stringResource(R.string.service_error_deprecated_warning_documentation))
Text(stringResource(R.string.error_deprecated_documentation))
}
}
} else {

View File

@@ -261,7 +261,7 @@ private fun ProfilePickerRow(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(R.string.profile_saved_successfully),
context.getString(R.string.success_profile_saved),
Toast.LENGTH_SHORT,
).show()
}
@@ -269,7 +269,7 @@ private fun ProfilePickerRow(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"${context.getString(R.string.profile_save_failed)}: ${e.message}",
"${context.getString(R.string.failed_save_profile)}: ${e.message}",
Toast.LENGTH_SHORT,
).show()
}

View File

@@ -215,7 +215,7 @@ fun ProfilesCard(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(R.string.profile_saved_successfully),
context.getString(R.string.success_profile_saved),
Toast.LENGTH_SHORT,
).show()
}
@@ -223,7 +223,7 @@ fun ProfilesCard(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"${context.getString(R.string.profile_save_failed)}: ${e.message}",
"${context.getString(R.string.failed_save_profile)}: ${e.message}",
Toast.LENGTH_SHORT,
).show()
}

View File

@@ -438,14 +438,14 @@ fun LogScreen(
outputStream.flush()
Toast.makeText(
context,
context.getString(R.string.logs_saved_successfully),
context.getString(R.string.success_logs_saved),
Toast.LENGTH_SHORT,
).show()
}
} catch (e: Exception) {
Toast.makeText(
context,
context.getString(R.string.failed_to_save_logs, e.message),
context.getString(R.string.failed_save_logs, e.message),
Toast.LENGTH_SHORT,
).show()
}
@@ -667,7 +667,7 @@ fun LogScreen(
} catch (e: Exception) {
Toast.makeText(
context,
context.getString(R.string.failed_to_share_logs, e.message),
context.getString(R.string.failed_share_logs, e.message),
Toast.LENGTH_SHORT,
).show()
}

View File

@@ -125,7 +125,7 @@ fun EditProfileContentScreen(
if (uiState.showSaveSuccessMessage) {
Toast.makeText(
context,
context.getString(R.string.configuration_saved),
context.getString(R.string.success_configuration_saved),
Toast.LENGTH_SHORT,
).show()
viewModel.clearSaveSuccessMessage()

View File

@@ -334,7 +334,7 @@ class EditProfileViewModel(application: Application) : AndroidViewModel(applicat
Toast.makeText(
context,
context.getString(
io.nekohasekai.sfa.R.string.failed_to_read_configuration,
io.nekohasekai.sfa.R.string.failed_read_configuration,
e.message,
),
Toast.LENGTH_SHORT,

View File

@@ -215,7 +215,7 @@ fun SettingsScreen(navController: NavController) {
ListItem(
headlineContent = {
Text(
stringResource(R.string.service_error_deprecated_warning_documentation),
stringResource(R.string.error_deprecated_documentation),
style = MaterialTheme.typography.bodyLarge,
)
},

View File

@@ -81,7 +81,7 @@ suspend fun saveQRCodeToGallery(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(io.nekohasekai.sfa.R.string.failed_to_save_qr_code, e.message),
context.getString(io.nekohasekai.sfa.R.string.failed_save_qr_code, e.message),
Toast.LENGTH_LONG,
).show()
e.printStackTrace()
@@ -137,7 +137,7 @@ suspend fun shareQRCodeImage(
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(io.nekohasekai.sfa.R.string.failed_to_share_qr_code, e.message),
context.getString(io.nekohasekai.sfa.R.string.failed_share_qr_code, e.message),
Toast.LENGTH_LONG,
).show()
e.printStackTrace()