JourneyTrack is a simple Android application that helps you track your journey stops and distances. This README document will guide you through the key aspects of the working of the application, with a focus on the MainActivity.kt and its associated XML layout file (activity_main.xml).
JourneyTrack is designed to display a list of stops along a journey, allowing you to track the total distance covered and remaining distance. The main screen (MainActivity) provides an interactive interface to view and navigate through the stops.
The application consists of the following components:
- Splash Activity (SplashActivity.kt and activity_splash.xml):
- The splash screen is a visual introduction to the app displayed when the application is launched.
- SplashActivity.kt initiates the splash screen with a GIF image and transitions to MainActivity after a brief delay.
- Main Activity (MainActivity.kt and activity_main.xml):
- The central part of the application that displays the list of stops, progress bar, and other UI elements.
- Data Model (Stop class):
- The Stop data class represents a single stop with a name and distance in kilometers. This class is utilized to structure the stops for the journey.
Buttons and Switches:
btnNextStop
: Button to navigate to the next stop.switchUnits
: Switch for toggling between displaying distances in kilometers or miles.switchLists
: Switch for toggling between normal and lazy stops lists.
TextViews:
tvTotalDistanceCovered
andtvTotalDistanceRemaining
: Display the total distance covered and remaining in the journey.
Lists of Stops:
normalStops
andlazyStops
: Lists containing stops with their respective distances.
State Variables:
currentStop
: Tracks the index of the current stop.useLazyStops
: Tracks whether to use normal or lazy stops.progressState
: Maintains the progress state for the progress bar.
-
onCreate
: Initializes the UI elements and sets up listeners for switches and buttons. Displays the initial set of stops based on the default configuration. -
displayStops
: Updates the UI to display stops based on the current configuration. -
StopsList
andLazyStopsList
Composables: Composable functions to display lists of stops using Jetpack Compose. -
StopCard
Composable: Composable function to display a card for each stop in the list. -
calculateTotalDistanceCovered
andcalculateTotalDistanceRemaining
: Functions to compute the total distance covered and remaining based on the selected stops. -
ProgressBar
andupdateProgressBar
: Functions to display and update the progress bar. -
showToast
: Displays toast messages for specific events.
AppLogo
Composable - Displays the application logo using Jetpack Compose.ProgressBar
Composable - Creates a linear progress bar using Jetpack Compose.
ComposeView Elements:
logo_view
,progress_view
,compose_view
: Integration of Jetpack Compose elements within the XML layout.
TextViews:
tv_total_distance_covered
andtv_total_distance_remaining
: Display total distances and are dynamically updated in theStopsList
andLazyStopsList
composables.
- Glide Library - Utilized to load and display GIF images efficiently.
- The app starts with a splash screen displaying the application logo.
- After the splash screen, you are directed to the main screen where you can:
- Toggle between kilometers and miles.
- Toggle between normal and lazy stops.
- Navigate to the next stop using the "Next Stop" button.
- View the total distance covered and remaining.
- Stop Lists:
- The main screen displays either normal or lazy stops based on the selected configuration.
- Progress Bar:
- The progress bar at the top updates every time the user navigates to the next stop.