Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
yasanglass committed Apr 4, 2022
2 parents 22296de + f13b48b commit 85c012d
Show file tree
Hide file tree
Showing 83 changed files with 963 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Android CI
on:
push:
branches: [ main, telemetry ]
branches: [ main ]
pull_request:
branches: [ '*' ]
workflow_dispatch:
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Tehro Changelog

## Unreleased
## v2.3.1

- Added station search support.
- Fixed map loading indicator's exit animation.

## v2.3.0

- Fixed state restore if the app process was killed on the line screen.
- Line screen navigations no longer stack on top of each other and only the last one is kept.
- Added Firebase (Analytics, Crashlytics & Performance) on GitHub & Play builds.

## v2.2.1

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tehro is a guide app for Tehran Metro powered by [Jetpack Compose](https://devel

You can get the official releases from either [GitHub](https://github.com/yasandev/tehro-android/releases), [F-Droid](https://f-droid.org/packages/dev.yasan.metro.fdroid/) or [Google Play Store](https://play.google.com/store/apps/details?id=dev.yasan.metro).

The F-Droid releases **do not** have internet access permission & any telemetry. The GitHub & Google Play Store releases **do** have Firebase telemetry.
**Note:** The F-Droid releases do **not** have internet access permission & any telemetry. The GitHub & Google Play Store releases do have Firebase telemetry.

## Database

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
minSdk 21
targetSdk 31

versionCode 230
versionName "2.3.0"
versionCode 231
versionName "2.3.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package dev.yasan.metro.tehran.data.db
import androidx.room.Database
import androidx.room.RoomDatabase
import dev.yasan.metro.tehran.data.db.dao.*
import dev.yasan.metro.tehran.data.db.entity.*
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.data.db.entity.accessibility.WcAvailabilityLevel
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.model.tehro.accessibility.WcAvailabilityLevel
import dev.yasan.metro.tehran.model.tehro.DatabaseInformation
import dev.yasan.metro.tehran.model.tehro.Intersection
import dev.yasan.metro.tehran.model.tehro.Line
import dev.yasan.metro.tehran.model.tehro.Station
import javax.inject.Inject

@Database(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelBlindness

/**
* Data access object for [AccessibilityLevelBlindness].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelWheelchair

/**
* Data access object for [AccessibilityLevelWheelchair].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.DatabaseInformation
import dev.yasan.metro.tehran.model.tehro.DatabaseInformation

/**
* Data access object for [DatabaseInformation].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Intersection
import dev.yasan.metro.tehran.model.tehro.Intersection

/**
* Data access object for [Intersection].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Line
import dev.yasan.metro.tehran.model.tehro.Line

/**
* Data access object for [Line].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.model.tehro.Station

/**
* Data access object for [Station].
Expand Down Expand Up @@ -31,4 +31,10 @@ interface StationDAO {
@Query("SELECT * FROM stations WHERE line_id=:lineId")
suspend fun getByLineId(lineId: Int): List<Station>

/**
* @return A [Station] that matches the query if any exist.
*/
@Query("SELECT * FROM stations WHERE name_en LIKE '%' || :query || '%' OR name_fa LIKE '%' || :query || '%' ORDER BY name_en COLLATE NOCASE ASC")
suspend fun search(query: String): List<Station>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package dev.yasan.metro.tehran.data.db.dao
import androidx.room.Dao
import androidx.room.Query
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.data.db.entity.accessibility.WcAvailabilityLevel
import dev.yasan.metro.tehran.model.tehro.accessibility.WcAvailabilityLevel

/**
* Data access object for [WcAvailabilityLevel].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package dev.yasan.metro.tehran.data.repo.station.accessibility
package dev.yasan.metro.tehran.data.repository.accessibility

import android.util.Log
import dev.yasan.metro.tehran.data.db.dao.AccessibilityLevelBlindnessDAO
import dev.yasan.metro.tehran.data.db.dao.AccessibilityLevelWheelchairDAO
import dev.yasan.metro.tehran.data.db.dao.StationDAO
import dev.yasan.metro.tehran.data.db.dao.WcAvailabilityLevelDAO
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.data.db.entity.accessibility.WcAvailabilityLevel
import dev.yasan.metro.tehran.data.repo.intersection.IntersectionRepository
import dev.yasan.metro.tehran.data.repo.line.LineRepository
import dev.yasan.metro.tehran.domain.repository.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.model.tehro.accessibility.WcAvailabilityLevel
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.yasan.metro.tehran.data.repo.dbinfo
package dev.yasan.metro.tehran.data.repository.dbinfo

import dev.yasan.metro.tehran.data.db.dao.DatabaseInformationDAO
import dev.yasan.metro.tehran.data.db.entity.DatabaseInformation
import dev.yasan.metro.tehran.domain.repository.dbinfo.DatabaseInformationRepository
import dev.yasan.metro.tehran.model.tehro.DatabaseInformation
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.yasan.metro.tehran.data.repo.intersection
package dev.yasan.metro.tehran.data.repository.intersection

import dev.yasan.metro.tehran.data.db.dao.IntersectionDAO
import dev.yasan.metro.tehran.data.db.entity.Intersection
import dev.yasan.metro.tehran.domain.repository.intersection.IntersectionRepository
import dev.yasan.metro.tehran.model.tehro.Intersection
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.yasan.metro.tehran.data.repo.line
package dev.yasan.metro.tehran.data.repository.line

import dev.yasan.metro.tehran.data.db.dao.LineDAO
import dev.yasan.metro.tehran.data.db.entity.Line
import dev.yasan.metro.tehran.domain.repository.line.LineRepository
import dev.yasan.metro.tehran.model.tehro.Line
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package dev.yasan.metro.tehran.data.repo.stat
package dev.yasan.metro.tehran.data.repository.stat

import dev.yasan.metro.tehran.R
import dev.yasan.metro.tehran.data.db.dao.*
import dev.yasan.metro.tehran.data.db.entity.Stat
import dev.yasan.metro.tehran.data.db.entity.StatComplex
import dev.yasan.metro.tehran.data.repo.station.StationRepository
import dev.yasan.metro.tehran.data.repo.station.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.model.tehro.Stat
import dev.yasan.metro.tehran.model.tehro.StatComplex
import dev.yasan.metro.tehran.domain.repository.station.StationRepository
import dev.yasan.metro.tehran.domain.repository.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.domain.repository.stat.StatRepository
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dev.yasan.metro.tehran.data.repo.station
package dev.yasan.metro.tehran.data.repository.station

import dev.yasan.metro.tehran.data.db.dao.StationDAO
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.repo.intersection.IntersectionRepository
import dev.yasan.metro.tehran.data.repo.line.LineRepository
import dev.yasan.metro.tehran.data.repo.station.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.domain.repository.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.domain.repository.intersection.IntersectionRepository
import dev.yasan.metro.tehran.domain.repository.line.LineRepository
import dev.yasan.metro.tehran.domain.repository.station.StationRepository
import dev.yasan.metro.tehran.model.tehro.Station
import javax.inject.Inject

/**
Expand Down Expand Up @@ -54,6 +55,9 @@ class StationRepositoryImp @Inject constructor(
}

override suspend fun fetchAdditionalStationData(station: Station): Station {

station.line = lineRepository.getLine(lineId = station.lineId)

intersectionRepository.getIntersectionByStationId(stationId = station.id)
?.let { intersection ->
intersection.stationA =
Expand Down Expand Up @@ -94,4 +98,10 @@ class StationRepositoryImp @Inject constructor(
}
}

override suspend fun searchStations(complete: Boolean, query: String): List<Station> {
val stations = stationDAO.search(query = query)
return if (complete) fetchAdditionalStationData(stations = stations)
else stations
}

}
24 changes: 12 additions & 12 deletions app/src/main/java/dev/yasan/metro/tehran/di/ApplicationModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import dagger.hilt.components.SingletonComponent
import dev.yasan.kit.core.DispatcherProvider
import dev.yasan.metro.tehran.data.db.MetroDatabase
import dev.yasan.metro.tehran.data.db.dao.*
import dev.yasan.metro.tehran.data.repo.dbinfo.DatabaseInformationRepository
import dev.yasan.metro.tehran.data.repo.dbinfo.DatabaseInformationRepositoryImp
import dev.yasan.metro.tehran.data.repo.intersection.IntersectionRepository
import dev.yasan.metro.tehran.data.repo.intersection.IntersectionRepositoryImp
import dev.yasan.metro.tehran.data.repo.line.LineRepository
import dev.yasan.metro.tehran.data.repo.line.LineRepositoryImp
import dev.yasan.metro.tehran.data.repo.stat.StatRepository
import dev.yasan.metro.tehran.data.repo.stat.StatRepositoryImp
import dev.yasan.metro.tehran.data.repo.station.StationRepository
import dev.yasan.metro.tehran.data.repo.station.StationRepositoryImp
import dev.yasan.metro.tehran.data.repo.station.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.data.repo.station.accessibility.AccessibilityRepositoryImp
import dev.yasan.metro.tehran.domain.repository.dbinfo.DatabaseInformationRepository
import dev.yasan.metro.tehran.data.repository.dbinfo.DatabaseInformationRepositoryImp
import dev.yasan.metro.tehran.domain.repository.intersection.IntersectionRepository
import dev.yasan.metro.tehran.data.repository.intersection.IntersectionRepositoryImp
import dev.yasan.metro.tehran.domain.repository.line.LineRepository
import dev.yasan.metro.tehran.data.repository.line.LineRepositoryImp
import dev.yasan.metro.tehran.domain.repository.stat.StatRepository
import dev.yasan.metro.tehran.data.repository.stat.StatRepositoryImp
import dev.yasan.metro.tehran.domain.repository.station.StationRepository
import dev.yasan.metro.tehran.data.repository.station.StationRepositoryImp
import dev.yasan.metro.tehran.domain.repository.accessibility.AccessibilityRepository
import dev.yasan.metro.tehran.data.repository.accessibility.AccessibilityRepositoryImp
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import javax.inject.Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.yasan.metro.tehran.data.repo.station.accessibility
package dev.yasan.metro.tehran.domain.repository.accessibility

import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.data.db.entity.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.data.db.entity.accessibility.WcAvailabilityLevel
import dev.yasan.metro.tehran.model.tehro.Station
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelBlindness
import dev.yasan.metro.tehran.model.tehro.accessibility.AccessibilityLevelWheelchair
import dev.yasan.metro.tehran.model.tehro.accessibility.WcAvailabilityLevel

/**
* Handles all data related to [Station] accessibility.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.yasan.metro.tehran.data.repo.dbinfo
package dev.yasan.metro.tehran.domain.repository.dbinfo

import dev.yasan.metro.tehran.data.db.dao.DatabaseInformationDAO
import dev.yasan.metro.tehran.data.db.entity.DatabaseInformation
import dev.yasan.metro.tehran.model.tehro.DatabaseInformation

/**
* Handles all data related to [DatabaseInformation]s.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.yasan.metro.tehran.data.repo.intersection
package dev.yasan.metro.tehran.domain.repository.intersection

import dev.yasan.metro.tehran.data.db.dao.IntersectionDAO
import dev.yasan.metro.tehran.data.db.entity.Intersection
import dev.yasan.metro.tehran.model.tehro.Intersection

/**
* Handles all data related to [Intersection].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.yasan.metro.tehran.data.repo.line
package dev.yasan.metro.tehran.domain.repository.line

import dev.yasan.metro.tehran.data.db.dao.LineDAO
import dev.yasan.metro.tehran.data.db.entity.Line
import dev.yasan.metro.tehran.model.tehro.Line

/**
* Handles all data related to [Line].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.yasan.metro.tehran.data.repo.stat
package dev.yasan.metro.tehran.domain.repository.stat

import dev.yasan.metro.tehran.data.db.entity.Stat
import dev.yasan.metro.tehran.data.db.entity.StatComplex
import dev.yasan.metro.tehran.model.tehro.Stat
import dev.yasan.metro.tehran.model.tehro.StatComplex

/**
* Handles all data related to [Stat].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.yasan.metro.tehran.data.repo.station
package dev.yasan.metro.tehran.domain.repository.station

import dev.yasan.metro.tehran.data.db.dao.StationDAO
import dev.yasan.metro.tehran.data.db.entity.Station
import dev.yasan.metro.tehran.model.tehro.Station

/**
* Handles all data related to [Station].
Expand All @@ -16,7 +16,10 @@ interface StationRepository {
*
* @see StationDAO
*/
suspend fun getStations(complete: Boolean = false, removeDuplicate: Boolean = false): List<Station>
suspend fun getStations(
complete: Boolean = false,
removeDuplicate: Boolean = false
): List<Station>

/**
* @return A list of all [Station]s in the line with the matching [lineId].
Expand Down Expand Up @@ -48,4 +51,6 @@ interface StationRepository {
*/
suspend fun fetchAdditionalStationData(stations: List<Station>): List<Station>

suspend fun searchStations(complete: Boolean, query: String): List<Station>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.yasan.metro.tehran.model.misc

/**
* Indicates the source of the launch.
*
* Used on some composables to customize the interface & behavior based on it as a better alternative to boolean parameters.
*/
enum class LaunchSource {
INVALID,
HOME,
LINE,
SEARCH,
MAP;

companion object {

fun fromInt(int: Int) = LaunchSource.values().getOrNull(int) ?: INVALID

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.yasan.metro.tehran.data.db.entity
package dev.yasan.metro.tehran.model.tehro

import androidx.room.ColumnInfo
import androidx.room.Entity
Expand Down
Loading

0 comments on commit 85c012d

Please sign in to comment.