Code Monkey home page Code Monkey logo

stationdistancechecker's Introduction

Station Distance Checker

An Android application for calculating the distance between two railway stations. It calculates the distance between selected stations and utilizes the Google Maps API for data visualization on the map. The application is written in Kotlin and uses the latest practices and tools from the Android ecosystem.

Features

  • Searching for railway stations by name.
  • Calculating the distance between selected stations.
  • Displaying results on the map.

Used Technologies and Libraries

The application utilizes the following technologies and libraries:

  • Kotlin
  • Android Jetpack (Compose, ViewModel, Flow, Room) - Room is used to store data about stations and distances locally on the device, allowing for fast access and operations even without network access.
  • Google Maps API
  • Retrofit - for API communication
  • Koin - as a dependency management system
  • Coroutines - for asynchronous operation handling
  • JUnit, MockK - for testing
  • and others full list

Running the Application

To run the application, you have two options:

Option 1: Running from Source Code

To run the application, you need a Google Maps API key. Obtain it from Create API keys and add it to the local.defaults.properties file by replacing MAPS_API_KEY=DEFAULT_API_KEY with your own API key.

Option 2: Installing the APK from Releases

You can download the latest APK version from the Releases section in the GitHub repository and install it directly on your Android device.

Unit Testing

The application leverages JUnit5 and MockK for unit testing, focusing on the business logic to ensure the components of the application function correctly without the need for running an Android environment.

Setting Up the Unit Testing Environment

To run the unit tests, a JDK environment is required (version 17 is recommended) along with Gradle.

Running Unit Tests

Unit tests can be run directly from Android Studio or via the command line. Instructions for both methods are provided below:

Running from Android Studio

  1. Open the test class, e.g., StationSpanRepositoryTest, in Android Studio.
  2. Right-click on the class name or a specific test and select Run 'StationSpanRepositoryTest' or Run 'testName'.

Running from the Command Line

  1. Open a terminal in the root directory of the project.
  2. Execute the following command to run all unit tests:
    ./gradlew test

UI Tests

The application utilizes Android Jetpack Compose for building its user interface and the androidx.compose.ui.test library for testing these UI components. UI tests focus on verifying user interactions with the application, such as searching for stations and calculating and displaying the distance between selected stations.

Setting Up the Environment for UI Tests

To run the UI tests, you will need:

  1. Android Studio environment with Android SDK installed.
  2. An Android Emulator installed and configured or a physical device connected.

Running UI Tests

UI tests can be run directly from Android Studio or using the command line. Below are the instructions for both methods:

Running from Android Studio

  1. Open the test class StationSearchDistanceTest in Android Studio.
  2. Right-click on the class name or a test method and select Run 'StationSearchDistanceTest' or Run 'testSearchAndDisplayDistanceBetweenStations'.

Running from Command Line

  1. Open a terminal in the root directory of the project.
  2. Execute the following command to run all UI tests:
    ./gradlew connectedAndroidTest

Continuous Integration (CI)

The project uses GitHub Actions for automatically running unit tests for every pull request to the main and dev branches.

CI Workflow

The CI process consists of the following steps:

  • Check out code: Clones the repository for running GitHub actions.
  • Install Unzip: Prepares the environment by installing necessary tools.
  • Set up JDK 17: Configures Java Development Kit 17 for building Android projects.
  • Set up Android SDK: Prepares the Android SDK environment for building and testing the application.
  • Grant execute permission for gradlew: Ensures the Gradle wrapper script is executable.
  • Run Check: Executes the ./gradlew check command, which runs all configured checks, such as unit tests.

The workflow is defined in the .github/workflows directory of the repository and is triggered for every pull request to the main and dev branches. It runs on a self-hosted runner, ensuring a consistent and controlled testing environment.

CI Environment Settings

The CI process is designed to run on a self-hosted machine, which requires manual configuration. To replicate the CI environment or configure a new self-hosted runner, ensure the following requirements are met:

  1. Self-Hosted Runner: Follow GitHub's documentation to set up a self-hosted runner.
  2. JDK 17: Install JDK 17, which is required for building Android projects.
  3. Android SDK: Install and configure the Android SDK with necessary tools and platforms.
  4. Environment Variables: Set up any necessary environment variables, such as ANDROID_HOME, pointing to the location of the Android SDK.

stationdistancechecker's People

Contributors

stanislawm97 avatar

Watchers

 avatar

stationdistancechecker's Issues

Unintended Keyboard Closure upon Search Input Clearance

An issue has been identified within the application where the on-screen keyboard unexpectedly closes upon the clearing of all text from the search input field. This behavior diverges from expected functionality, where the keyboard should remain visible, allowing for uninterrupted text entry following the removal of a previous search query.

Expected Behavior:
Upon the deletion of text from the search input field, the on-screen keyboard should persist, enabling the user to immediately proceed with entering a new query without the necessity of reactivating the keyboard.

Steps to Reproduce:

  1. Access the station search feature within the application.
  2. Activate the search input field, causing the on-screen keyboard to appear.
  3. Input any sequence of characters into the field.
  4. Remove all characters from the search input field.

Observed Outcome:
The on-screen keyboard retracts upon the complete removal of text from the search input field.

Desired Outcome:
The on-screen keyboard should remain active, facilitating seamless transition to entering subsequent search terms.

Station Search Error: Incorrect Use of Keyword Instead of Station Name

In the application designed for searching railway stations based on a provided keyword, an error occurred causing the search mechanism to incorrectly interpret the input text as a keyword (keyword) rather than the expected station name (title). This issue led to improper search results because the system did not query the database for matching station names but looked for matches to the keyword instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.