Skip to content

Conversation

@ardevd
Copy link
Owner

@ardevd ardevd commented Jan 25, 2026

No description provided.

@ardevd ardevd self-assigned this Jan 25, 2026
@ardevd ardevd added the enhancement New feature or request label Jan 25, 2026
Copilot AI review requested due to automatic review settings January 25, 2026 17:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors authentication error handling to support localization by introducing a UIText wrapper class. The changes enable error messages to be displayed in the user's language while maintaining flexibility for dynamic error content.

Changes:

  • Introduced a UIText sealed class to handle both string resources and dynamic strings
  • Updated LoginUiState.Error to use UIText instead of raw String
  • Added localized error message string resources for authentication failures
  • Modified LoginFragment to resolve UIText to displayable strings using asString()

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
app/src/main/java/net/ardevd/tagius/core/ui/UIText.kt New sealed class providing abstraction for localized and dynamic strings
app/src/main/java/net/ardevd/tagius/features/auth/viewmodel/LoginUiState.kt Changed Error state to use UIText; updated error handling to use localized resources
app/src/main/java/net/ardevd/tagius/features/auth/ui/LoginFragment.kt Updated error handling to resolve UIText to strings using asString()
app/src/main/res/values/strings.xml Added four new localized error message strings for authentication failures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} catch (e: IOException) {
// Network Errors (DNS, Connection Refused, Timeout)
_uiState.value = LoginUiState.Error("Could not connect to server. ${e.message}", ErrorField.URL)
emitError(UIText.StringResource(R.string.error_connection_failed), ErrorField.URL)
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous error message included the exception details (e.message), which could provide valuable debugging information to users. The new localized message removes this context. Consider adding the exception message as a format parameter to the string resource, or falling back to DynamicString if you want to preserve the original exception message for debugging purposes.

Suggested change
emitError(UIText.StringResource(R.string.error_connection_failed), ErrorField.URL)
emitError(
UIText.DynamicString(e.localizedMessage ?: "Connection failed"),
ErrorField.URL
)

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +12
class StringResource(
@StringRes val resId: Int,
vararg val args: Any // Allows for format arguments like "Error: %d"
) : UIText()
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making StringResource a data class for consistency with DynamicString. This would provide automatic equals(), hashCode(), and toString() implementations, which could be useful if these objects are ever compared or used in collections. Since vararg parameters cannot be used in data class constructors directly, you could convert the vararg to a regular Array parameter: data class StringResource(@stringres val resId: Int, val args: Array<out Any> = emptyArray())

Suggested change
class StringResource(
@StringRes val resId: Int,
vararg val args: Any // Allows for format arguments like "Error: %d"
) : UIText()
data class StringResource(
@StringRes val resId: Int,
val args: Array<out Any> = emptyArray() // Allows for format arguments like "Error: %d"
) : UIText() {
constructor(
@StringRes resId: Int,
vararg args: Any
) : this(resId, args)
}

Copilot uses AI. Check for mistakes.
@ardevd ardevd merged commit 3b7ea70 into main Jan 25, 2026
8 checks passed
@ardevd ardevd deleted the auth-error-string-resources branch January 25, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants