diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19e6ea9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Android Studio +*.iml +.gradle/ +build/ +.idea/ +local.properties + +# Gradle files +*.gradle +**/build/ + +# Compiled class files +*.class + +# Log files +*.log + +# Virtual machine crash logs +hs_err_pid* + +# Mac system files +.DS_Store + +# Sensitive or local configuration +*.env + +# External libraries +app/libs/ + +# Test results +test-results/ +reports/ \ No newline at end of file diff --git a/app/src/main/java/com/example/todoapp/data/TodoItem.kt b/app/src/main/java/com/example/todoapp/data/TodoItem.kt new file mode 100644 index 0000000..ec557a9 --- /dev/null +++ b/app/src/main/java/com/example/todoapp/data/TodoItem.kt @@ -0,0 +1,13 @@ +package com.example.todoapp.data + +data class TodoItem( + val id: Long = 0, // Default 0 for new items + val title: String, + val description: String = "", + val isCompleted: Boolean = false +) { + // Validation method + fun validate(): Boolean { + return title.isNotBlank() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/todoapp/ui/AddTodoActivity.kt b/app/src/main/java/com/example/todoapp/ui/AddTodoActivity.kt new file mode 100644 index 0000000..456b3c3 --- /dev/null +++ b/app/src/main/java/com/example/todoapp/ui/AddTodoActivity.kt @@ -0,0 +1,52 @@ +package com.example.todoapp.ui + +import android.os.Bundle +import android.widget.Button +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.textfield.TextInputEditText +import com.example.todoapp.R +import com.example.todoapp.data.TodoItem + +class AddTodoActivity : AppCompatActivity() { + private lateinit var titleEditText: TextInputEditText + private lateinit var descriptionEditText: TextInputEditText + private lateinit var saveButton: Button + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_add_todo) + + // Initialize views + titleEditText = findViewById(R.id.titleEditText) + descriptionEditText = findViewById(R.id.descriptionEditText) + saveButton = findViewById(R.id.saveButton) + + // Set up save button click listener + saveButton.setOnClickListener { + saveTodoItem() + } + } + + private fun saveTodoItem() { + val title = titleEditText.text.toString().trim() + val description = descriptionEditText.text.toString().trim() + + // Basic validation + if (title.isEmpty()) { + titleEditText.error = "Title cannot be empty" + return + } + + // Create TodoItem (assuming TodoItem class exists) + val todoItem = TodoItem( + title = title, + description = description, + isCompleted = false + ) + + // TODO: Save to repository or database + Toast.makeText(this, "Todo saved!", Toast.LENGTH_SHORT).show() + finish() // Close the activity after saving + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_add_todo.xml b/app/src/main/res/layout/activity_add_todo.xml new file mode 100644 index 0000000..db936e8 --- /dev/null +++ b/app/src/main/res/layout/activity_add_todo.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + +