diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/ApiUnreachableActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/ApiUnreachableActivity.kt
index a2fd6c0..f17b131 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/ApiUnreachableActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/ApiUnreachableActivity.kt
@@ -11,7 +11,6 @@ import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
-import com.google.android.material.card.MaterialCardView
import com.p_vacho.neat_calendar.R
import com.p_vacho.neat_calendar.api.RetrofitClient
import com.p_vacho.neat_calendar.util.ExceptionSerializer
diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/CreateEventActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/CreateEventActivity.kt
index 2dcac46..737ef03 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/CreateEventActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/CreateEventActivity.kt
@@ -183,7 +183,8 @@ class CreateEventActivity : AppCompatActivity() {
val defaultDateTime = endDateTime ?: startDateTime ?: defaultDate.atTime(12, 0)
showDateTimePicker(defaultDateTime) { selectedDateTime ->
if (!selectedDateTime.isAfter(startDateTime)) {
- Toast.makeText(this, "End time must be after start time", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this,
+ getString(R.string.end_time_must_be_after_start_time), Toast.LENGTH_SHORT).show()
} else {
endDateTime = selectedDateTime
txtEndTime.setText(formatDateTime(selectedDateTime))
@@ -201,7 +202,8 @@ class CreateEventActivity : AppCompatActivity() {
val userId = (application as MyApplication).tokenManager.userId
if (userId.isNullOrEmpty()) {
- Toast.makeText(this, "User not authenticated. Unable to fetch categories.", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this,
+ getString(R.string.user_not_authenticated_unable_to_fetch_categories), Toast.LENGTH_SHORT).show()
finish() // Close the activity if no user is authenticated
return
}
@@ -245,14 +247,14 @@ class CreateEventActivity : AppCompatActivity() {
}
if (selectableCategories.isEmpty()) {
- Toast.makeText(this, "No more categories to add", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, getString(R.string.no_more_categories_to_add), Toast.LENGTH_SHORT).show()
return
}
val categoryNames = selectableCategories.map { it.name }.toTypedArray()
val builder = android.app.AlertDialog.Builder(this)
- .setTitle("Add Category")
+ .setTitle(getString(R.string.add_category))
.setItems(categoryNames) { dialog, which ->
val selectedCategory = selectableCategories[which]
eventCategories.add(selectedCategory)
@@ -260,7 +262,7 @@ class CreateEventActivity : AppCompatActivity() {
updateCategoryView()
dialog.dismiss()
}
- .setNegativeButton("Cancel") { dialog, _ ->
+ .setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
dialog.dismiss()
}
@@ -291,12 +293,14 @@ class CreateEventActivity : AppCompatActivity() {
val description = etEventDescription.text.toString()
if (title.isEmpty() || startDateTime == null) {
- Toast.makeText(this, "Please provide a title and start time", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this,
+ getString(R.string.please_provide_a_title_and_start_time), Toast.LENGTH_SHORT).show()
return
}
if (!instantEvent && endDateTime == null) {
- Toast.makeText(this, "Please provide an end time or use an instant event", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this,
+ getString(R.string.please_provide_an_end_time_or_use_an_instant_event), Toast.LENGTH_SHORT).show()
return
}
@@ -343,7 +347,7 @@ class CreateEventActivity : AppCompatActivity() {
withContext(Dispatchers.Main) {
Toast.makeText(
this@CreateEventActivity,
- "Failed to save event: $errMsg",
+ getString(R.string.failed_to_save_event, errMsg),
Toast.LENGTH_SHORT
).show()
}
@@ -352,7 +356,7 @@ class CreateEventActivity : AppCompatActivity() {
}
private fun handleEventSaved(createdEvent: EventResponse) {
- Toast.makeText(this, "Event Saved: ${createdEvent.title}", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, getString(R.string.event_saved, createdEvent.title), Toast.LENGTH_SHORT).show()
if (existingEvent == null) {
val intent = Intent().apply {
@@ -388,7 +392,7 @@ class CreateEventActivity : AppCompatActivity() {
private fun openColorPickerDialog() {
ColorPickerDialog
.Builder(this)
- .setTitle("Choose Event Color") // TODO: Localize
+ .setTitle(getString(R.string.choose_event_color))
// setDefaultColor expects an int coming from a color resource
// we're instead passing the current color as Int, so it's not
// from a resource, which the linter doesn't like, so suppress it
@@ -402,7 +406,9 @@ class CreateEventActivity : AppCompatActivity() {
}
private fun formatDateTime(dateTime: LocalDateTime?): String {
- return dateTime?.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) ?: "Select Time"
+ return dateTime?.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) ?: getString(
+ R.string.select_time
+ )
}
private fun updateCategoryView() {
diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/DayViewActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/DayViewActivity.kt
index 30f9798..48dde5b 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/DayViewActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/DayViewActivity.kt
@@ -177,7 +177,7 @@ class DayViewActivity : AppCompatActivity() {
withContext(Dispatchers.Main) {
Toast.makeText(
this@DayViewActivity,
- "Invitation sent to ${user.username}",
+ getString(R.string.invitation_sent_to, user.username),
Toast.LENGTH_SHORT
).show()
}
@@ -222,7 +222,7 @@ class DayViewActivity : AppCompatActivity() {
val userNames = users.map { it.username }.toTypedArray()
AlertDialog.Builder(this)
- .setTitle("Select a user to invite")
+ .setTitle(getString(R.string.select_a_user_to_invite))
.setItems(userNames) { dialog, which ->
// Pass the selected user back
onUserSelected(users[which])
diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/LoginActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/LoginActivity.kt
index 669eacc..ecb6fe4 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/LoginActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/LoginActivity.kt
@@ -50,7 +50,7 @@ class LoginActivity : AppCompatActivity() {
val password = passwordInput.text.toString().trim()
if (username.isEmpty() || password.isEmpty()) {
- Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, getString(R.string.please_fill_in_all_fields), Toast.LENGTH_SHORT).show()
} else {
performLogin(username, password)
}
@@ -72,16 +72,16 @@ class LoginActivity : AppCompatActivity() {
// Show the errors in a dialog
AlertDialog.Builder(this@LoginActivity)
- .setTitle("Validation Errors")
+ .setTitle(getString(R.string.validation_errors))
.setMessage(errorMessages)
- .setPositiveButton("OK", null)
+ .setPositiveButton(getString(R.string.ok), null)
.show()
}
is LoginResult.UnknownError -> {
Toast.makeText(
this@LoginActivity,
- "Login failed. Please try again.",
+ getString(R.string.login_failed_please_try_again),
Toast.LENGTH_LONG
).show()
}
diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/RegisterActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/RegisterActivity.kt
index 66c1628..955479f 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/RegisterActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/RegisterActivity.kt
@@ -65,7 +65,8 @@ class RegisterActivity : AppCompatActivity() {
val result = authRepository.register(username, password, email)
when (result) {
is RegisterResult.Success -> {
- Toast.makeText(this@RegisterActivity, "User registered, you may now log in", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this@RegisterActivity,
+ getString(R.string.user_registered_you_may_now_log_in), Toast.LENGTH_SHORT).show()
navigateToLoginActivity()
}
is RegisterResult.ValidationError -> {
@@ -76,16 +77,18 @@ class RegisterActivity : AppCompatActivity() {
// Show the errors in a dialog
AlertDialog.Builder(this@RegisterActivity)
- .setTitle("Validation Errors")
+ .setTitle(getString(R.string.validation_errors))
.setMessage(errorMessages)
.setPositiveButton("OK", null)
.show()
}
is RegisterResult.UserAlreadyExists -> {
- Toast.makeText(this@RegisterActivity, "User already exists. Please log in.", Toast.LENGTH_LONG).show()
+ Toast.makeText(this@RegisterActivity,
+ getString(R.string.user_already_exists_please_log_in), Toast.LENGTH_LONG).show()
}
is RegisterResult.UnknownError -> {
- Toast.makeText(this@RegisterActivity, "Registration failed. Try again later.", Toast.LENGTH_LONG).show()
+ Toast.makeText(this@RegisterActivity,
+ getString(R.string.registration_failed_try_again_later), Toast.LENGTH_LONG).show()
}
}
}
diff --git a/app/src/main/java/com/p_vacho/neat_calendar/activities/SettingsActivity.kt b/app/src/main/java/com/p_vacho/neat_calendar/activities/SettingsActivity.kt
index ceed7b7..bac42ce 100644
--- a/app/src/main/java/com/p_vacho/neat_calendar/activities/SettingsActivity.kt
+++ b/app/src/main/java/com/p_vacho/neat_calendar/activities/SettingsActivity.kt
@@ -111,19 +111,22 @@ class SettingsActivity : AppCompatActivity() {
throw e
}
- Toast.makeText(this@SettingsActivity, "This username or email is already taken", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this@SettingsActivity,
+ getString(R.string.username_or_email_is_already_taken), Toast.LENGTH_SHORT).show()
}
}
if (changed) {
- Toast.makeText(this@SettingsActivity, "Changes saved", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this@SettingsActivity,
+ getString(R.string.changes_saved), Toast.LENGTH_SHORT).show()
// Make a ping request, to re-check api connectivity
// TODO: Ping isn't a good enough check here, we should also validate tokens
withContext(Dispatchers.IO) {
RetrofitClient.ping()
}
} else {
- Toast.makeText(this@SettingsActivity, "No changes made", Toast.LENGTH_SHORT).show()
+ Toast.makeText(this@SettingsActivity,
+ getString(R.string.no_changes_made), Toast.LENGTH_SHORT).show()
}
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c70648e..631c067 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -53,4 +53,25 @@
Delete Account
Controls
Log out
+ Invitation sent to %1$s
+ Select a user to invite
+ This username or email is already taken
+ Changes saved
+ No changes made
+ User registered, you may now log in
+ Validation Errors
+ User already exists. Please log in.
+ Registration failed. Try again later.
+ Please fill in all fields
+ OK
+ Login failed. Please try again.
+ End time must be after start time
+ User not authenticated. Unable to fetch categories.
+ No more categories to add
+ Please provide a title and start time
+ Please provide an end time or use an instant event
+ Failed to save event: %1$s
+ Event Saved: %1$s
+ Choose Event Color
+ Select Time
\ No newline at end of file