Skip to content

Commit

Permalink
chore: fill translate to fr and reorganize strings
Browse files Browse the repository at this point in the history
  • Loading branch information
BatLeDev committed Jun 8, 2024
1 parent fea485d commit 08aef13
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 143 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/com/batledev/bluetask/CreateTaskActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CreateTaskActivity : AppCompatActivity() {

// Validate input data
if (title.isEmpty()) {
editTextTitle.error = "Title required"
editTextTitle.error = resources.getString(R.string.error_empty_title)
editTextTitle.requestFocus()
return
}
Expand Down Expand Up @@ -143,7 +143,8 @@ class CreateTaskActivity : AppCompatActivity() {
}
.addOnFailureListener { e ->
println("Error adding task: $e")
Toast.makeText(this, "Error adding task", Toast.LENGTH_SHORT).show()
Toast.makeText(this, resources.getString(R.string.error_create_task),
Toast.LENGTH_SHORT).show()
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/batledev/bluetask/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ class MainActivity : AppCompatActivity() {
private fun loadTasks() {
swipeRefreshLayout.isRefreshing = true

// Show/Hide the create task button
val createTaskButton = findViewById<Button>(R.id.createTaskButton)
createTaskButton.visibility = if (status == "active" && label.isEmpty()) View.VISIBLE else View.GONE

val userId = firebaseAuth.currentUser?.uid ?: return
var tasksRef = firestore.collection("users").document(userId)
.collection("tasks")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/batledev/bluetask/TaskAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TaskAdapter(context: Context, tasks: List<Task>, private val taskActivityL
if (task.title.isEmpty() && task.description.isEmpty()) {
titleTextView.visibility = View.GONE
descriptionTextView.visibility = View.VISIBLE
descriptionTextView.text = context.getString(R.string.empty_task_description)
descriptionTextView.text = context.getString(R.string.empty_title_description)
descriptionTextView.setTypeface(null, Typeface.ITALIC)
}
// If the title is empty, hide the title, same for the description
Expand Down
18 changes: 6 additions & 12 deletions app/src/main/java/com/batledev/bluetask/UpdateTaskActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class UpdateTaskActivity : AppCompatActivity() {

// Validate input data
if (title.isEmpty()) {
editTextTitle.error = "Title required"
editTextTitle.error = resources.getString(R.string.error_empty_title)
editTextTitle.requestFocus()
return
}
Expand Down Expand Up @@ -204,7 +204,7 @@ class UpdateTaskActivity : AppCompatActivity() {
}
.addOnFailureListener { e ->
println("Error updating task : $e")
Toast.makeText(this, resources.getString(R.string.update_error), Toast.LENGTH_SHORT).show()
Toast.makeText(this, resources.getString(R.string.error_update), Toast.LENGTH_SHORT).show()
}
}

Expand All @@ -218,25 +218,23 @@ class UpdateTaskActivity : AppCompatActivity() {
taskRef.delete()
.addOnSuccessListener {
println("Task deleted successfully")
Toast.makeText(this, resources.getString(R.string.delete_successful), Toast.LENGTH_SHORT).show()
setResult(RESULT_OK)
finish()
}
.addOnFailureListener { e ->
println("Error deleting task: $e")
Toast.makeText(this, resources.getString(R.string.update_error), Toast.LENGTH_SHORT).show()
Toast.makeText(this, resources.getString(R.string.error_update), Toast.LENGTH_SHORT).show()
}
} else {
taskRef.update("status", "deleted")
.addOnSuccessListener {
println("Task marked as deleted successfully")
Toast.makeText(this, resources.getString(R.string.trash_successful), Toast.LENGTH_SHORT).show()
setResult(RESULT_OK)
finish()
}
.addOnFailureListener { e ->
println("Error updating task : $e")
Toast.makeText(this, resources.getString(R.string.update_error), Toast.LENGTH_SHORT).show()
Toast.makeText(this, resources.getString(R.string.error_update), Toast.LENGTH_SHORT).show()
}
}
}
Expand All @@ -249,17 +247,13 @@ class UpdateTaskActivity : AppCompatActivity() {
val newStatus = if (taskDoc?.status == "archived") "active" else "archived"
taskRef.update("status", newStatus)
.addOnSuccessListener {
val message =
if (newStatus == "archived") resources.getString(R.string.archive_successful)
else resources.getString(R.string.unarchive_successful)
println(message)
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
println("Task archived/unarchived successfully")
setResult(RESULT_OK)
finish()
}
.addOnFailureListener { e ->
println("Error updating task : $e")
Toast.makeText(this, resources.getString(R.string.update_error), Toast.LENGTH_SHORT).show()
Toast.makeText(this, resources.getString(R.string.error_update), Toast.LENGTH_SHORT).show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ object TaskUtils {
} catch (e: ApiException) {
Toast.makeText(
activity,
"Google login/sign up failed: " + e.message,
Toast.LENGTH_SHORT
activity.resources.getString(R.string.error_auth_failed) + e.message,
Toast.LENGTH_LONG
).show()
}
}
Expand Down Expand Up @@ -84,7 +84,8 @@ object TaskUtils {
val user = hashMapOf(
"email" to currentUser.email,
"labels" to emptyList<String>(),
"createdAt" to FieldValue.serverTimestamp()
"createdAt" to FieldValue.serverTimestamp(),
"theme" to "dark"
)
userDoc.set(user).addOnSuccessListener { _ ->
updateUI(activity, currentUser)}
Expand All @@ -95,8 +96,8 @@ object TaskUtils {
} else {
Toast.makeText(
activity,
"Google login/sign up failed: " + task.exception!!.message,
Toast.LENGTH_SHORT
activity.resources.getString(R.string.error_auth_failed) + task.exception,
Toast.LENGTH_LONG
).show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class LoginActivity : AppCompatActivity() {

// Check if data is valid
if (TextUtils.isEmpty(email)) {
loginEmail.error = "Email is required."
loginEmail.error = resources.getString(R.string.error_email_required)
return
}
if (TextUtils.isEmpty(password)) {
loginPassword.error = "Password is required."
loginPassword.error = resources.getString(R.string.error_password_required)
return
}

Expand All @@ -79,10 +79,7 @@ class LoginActivity : AppCompatActivity() {
TaskUtils.updateUI(this, firebaseAuth.currentUser)
} else {
Toast.makeText(
baseContext,
"Login failed: " + task.exception?.message,
Toast.LENGTH_SHORT
).show()
this, resources.getString(R.string.error_auth_failed), Toast.LENGTH_LONG).show()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SignupActivity : AppCompatActivity() {
* - Check if the password is empty
* - Check if the password and confirm password match
* - Create a user with the email and password
* - If the user is created successfully, show a toast message and update the UI
* - If the user is created successfully, update the UI
*/
private fun registerUser() {
// Get and trim the email, password and confirm password
Expand All @@ -77,15 +77,15 @@ class SignupActivity : AppCompatActivity() {

// Check if data is valid
if (TextUtils.isEmpty(email)) {
signupEmail.error = "Email is required."
signupEmail.error = resources.getString(R.string.error_email_required)
return
}
if (TextUtils.isEmpty(password)) {
signupPassword.error = "Password is required."
signupPassword.error = resources.getString(R.string.error_password_required)
return
}
if (password != confirmPassword) {
signupConfirmPassword.error = "Passwords do not match."
signupConfirmPassword.error = resources.getString(R.string.error_password_mismatch)
return
}

Expand All @@ -98,7 +98,8 @@ class SignupActivity : AppCompatActivity() {
val user = hashMapOf(
"email" to currentUser.email,
"labels" to emptyList<String>(),
"createdAt" to FieldValue.serverTimestamp()
"createdAt" to FieldValue.serverTimestamp(),
"theme" to "dark"
)
firestore.collection("users").document(currentUser.uid)
.set(user)
Expand All @@ -107,10 +108,7 @@ class SignupActivity : AppCompatActivity() {
}
} else {
Toast.makeText(
baseContext,
"Registration failed: " + task.exception!!.message,
Toast.LENGTH_SHORT
).show()
this, resources.getString(R.string.error_auth_failed), Toast.LENGTH_LONG ).show()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_create_task.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/spinnerPriority"
android:layout_marginTop="8dp"
android:text="@string/selected_labels"
android:text="@string/labels_selected"
android:minHeight="48dp"
android:background="?android:attr/selectableItemBackground" />

Expand Down Expand Up @@ -76,7 +76,7 @@
android:id="@+id/buttonColorPicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/add_color"
android:text="@string/pick_color"
android:layout_below="@id/buttonEndDatePicker" />

<!-- Add Task Button -->
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:text="@string/login_to_bluetask"
android:text="@string/auth_login_page_title"
android:textColor="?attr/colorPrimary"
android:textSize="24sp"
android:textStyle="bold" />
Expand Down Expand Up @@ -69,7 +69,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/button_primary"
android:text="@string/login_with_google" />
android:text="@string/auth_login_with_google" />

<TextView
android:id="@+id/no_account"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
android:id="@+id/createTaskButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/create_new_task"
android:text="@string/create_task"
android:layout_margin="8dp"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:text="@string/sign_up_to_bluetask"
android:text="@string/auth_signup_page_title"
android:textColor="?attr/colorPrimary"
android:textSize="24sp"
android:textStyle="bold" />
Expand Down Expand Up @@ -79,7 +79,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/button_primary"
android:text="@string/sign_up_with_google" />
android:text="@string/auth_signup_with_google" />

<TextView
android:id="@+id/already_account"
Expand All @@ -88,7 +88,7 @@
android:layout_gravity="center_horizontal"
android:clickable="true"
android:minHeight="48dp"
android:text="@string/ask_already_login"
android:text="@string/ask_has_account"
android:gravity="center_vertical" />

</LinearLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_unlogged.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginBottom="16dp"
android:contentDescription="@string/icon_of_the_app"
android:contentDescription="@string/app_icon_description"
android:src="@drawable/logo"
tools:ignore="ImageContrastCheck" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_update_task.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/spinnerPriority"
android:layout_marginTop="8dp"
android:text="@string/selected_labels"
android:text="@string/labels_selected"
android:minHeight="48dp"
android:background="?android:attr/selectableItemBackground" />

Expand Down Expand Up @@ -76,7 +76,7 @@
android:id="@+id/buttonColorPicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/add_color"
android:text="@string/pick_color"
android:layout_below="@id/buttonEndDatePicker" />

<!-- Bottom Bar -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/drawer_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:title="@string/edit_labels" />

<item
android:title="@string/menu_bottom_section">
android:title="@string/other">
<menu>
<item
android:id="@+id/logout"
Expand Down
Loading

0 comments on commit 08aef13

Please sign in to comment.