This is a drawing app that allows users to create and manage drawings. Users can create new drawings, add markers to the drawings, and view details of each drawing.
- Create new drawings with a custom title and image
- Add markers to the drawings, specifying the marker position and title
- View the list of drawings with their respective marker counts
- Click on a drawing to view its details, including the markers
- Update the marker count of a drawing from the details screen
- Kotlin: Programming language used for the app development
- Android Jetpack: Collection of Android libraries and tools for app development
- ViewModel: Architecture component for managing and handling UI-related data
- LiveData: Observable data holder used for communication between components
- Room: Database library for data persistence
- RecyclerView: Component for displaying a scrollable list of items
- SQLite: Database used for storing the drawings and markers data
- Glide: Image loading library for loading and displaying images efficiently
- Material Design Components: UI components and design guidelines for a modern and intuitive user experience
The app follows the Model-View-ViewModel (MVVM) architecture pattern. The key components of the architecture are:
-The data layer of the app that includes entities, data access objects (DAOs), and the database.
-Entities: The data models that represent the core data structures in the app. In this project, we have two entities: Drawing and Marker.
@Entity(tableName = "drawings")
data class Drawing(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val title: String,
val imageUri: String,
val creationTime: Long,
var markerCount: Int
)
@Entity(tableName = "markers", foreignKeys = [ForeignKey(entity = Drawing::class, parentColumns = ["id"], childColumns = ["drawingId"], onDelete = ForeignKey.CASCADE)])
data class Marker(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val drawingId: Int,
var title: String,
val posX: Float,
val posY: Float,
val creationTime: Long
)
![Screenshot_20230513_012618](https://private-user-images.githubusercontent.com/72141924/238119443-48bb848d-2927-4680-bbdc-9cf3ff0454cc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMjUwMDcsIm5iZiI6MTcyNjEyNDcwNywicGF0aCI6Ii83MjE0MTkyNC8yMzgxMTk0NDMtNDhiYjg0OGQtMjkyNy00NjgwLWJiZGMtOWNmM2ZmMDQ1NGNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDA3MDUwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzMjYzMmFmYjE2N2M0MTAyY2M4YzYyMzVhYWViNzNjNDVjYmZjZWQ5MDA5YmU1ZTI0Y2EzMjJlMThmMDg2MjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.3jtYcfweqVucKk2YkC975EKsB7c24NKn8g9Fdx6waes)
![Screenshot_20230513_012637](https://private-user-images.githubusercontent.com/72141924/238119449-ef17b9e6-d309-4b0c-8e5e-93bccee0c113.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMjUwMDcsIm5iZiI6MTcyNjEyNDcwNywicGF0aCI6Ii83MjE0MTkyNC8yMzgxMTk0NDktZWYxN2I5ZTYtZDMwOS00YjBjLThlNWUtOTNiY2NlZTBjMTEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDA3MDUwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkxY2ZkOGUxYjk0ZjJlNTc4NjQwZTVhZDBiZDZiZWRmNzU5ODA4NzEyOGRkMjY0ODE3NjhjYTI0ODU0MTMxMmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BmZi7wEd9gziWzJogebDoDFqz5AtNlW5FWJMMWQLZVk)
-Data Access Objects (DAOs): The interfaces or classes that define the methods to interact with the database. They provide methods for performing CRUD (Create, Read, Update, Delete) operations on the entities. In this project, we have DAOs for Drawing and Marker
@Dao
interface DrawingDao {
@Query("SELECT * FROM drawings")
fun getAllDrawings(): LiveData<List<Drawing>>
// Other DAO methods omitted for brevity
}
@Dao
interface MarkerDao {
@Query("SELECT * FROM markers WHERE drawingId = :drawingId")
fun getMarkersForDrawing(drawingId: Int): LiveData<List<Marker>>
// Other DAO methods omitted for brevity
}
The database that holds the app's data. It is an abstraction layer on top of the underlying storage. In this project, we use Room Persistence Library, which is an SQLite object mapping library, as the database.
@Database(entities = [Drawing::class, Marker::class], version = 1, exportSchema = false)
abstract class DrawingDatabase : RoomDatabase() {
abstract fun drawingDao(): DrawingDao
abstract fun markerDao(): MarkerDao
// Database creation and migration code omitted for brevity
}
The UI layer of the app that includes activities, fragments, and XML layout files.
Activities and Fragments: The UI components responsible for displaying the app's screens and handling user interactions. In this project, we have the ProjectActivity as the main activity.
class ProjectActivity : AppCompatActivity() {
// Activity implementation omitted for brevity
}
Layout Files: The XML files that define the UI layout and components. In this project, we have layout files such as activity_project.xml and item_drawing.xml.
- The intermediary layer between the View and the Model that provides data to the UI and handles user interactions. It abstracts the UI from the underlying data sources and business logic.
DrawingViewModel: The ViewModel class that provides the necessary data for the ProjectActivity and handles data retrieval and updates.
class DrawingViewModel(private val repository: DrawingRepository) : ViewModel() {
val drawings: LiveData<List<Drawing>> = repository.getAllDrawings()
// Other ViewModel methods omitted for brevity
}
This architecture ensures separation of concerns and improves the maintainability and testability of the app by keeping the data, UI, and business logic
To build and run the app locally, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/drawing-app.git
- Open the project in Android Studio.
- Build and run the app on an emulator or a physical device.
Contributions to the project are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
This project is licensed under the MIT License.