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 May 12, 2022
2 parents d1f7c95 + a1f78a0 commit 3f9f11d
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ydk"]
path = ydk
url = git@github.com:yasandev/ydk-android.git
url = git@github.com:yasan-org/ydk-android.git
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Tehro Changelog

## v2.3.3

- Added almost all of the missing station locations.
- Improved how station locations are launched on supported map apps.
- Updated social links.

## v2.3.2

- The search button is now moved to the top of screen.
- Added the new option to reverse the order of stations on Line screen with a button.
- Fixed stations not being sorted by their position in line on Line screen.
- The search button is now moved to the top of the screen.
- Added the new option to reverse the order of stations on the Line screen with a button.
- Fixed stations not being sorted by their position in line on the Line screen.
- Added Android TV banner.
- Added Android TV (leanback) launcher support.

Expand Down
8 changes: 4 additions & 4 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 232
versionName "2.3.2"
versionCode 233
versionName "2.3.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -130,7 +130,7 @@ dependencies {
kapt "androidx.room:room-compiler:$room_version"

// Leak Canary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'

// Subsampling Scale ImageView
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
Expand All @@ -147,7 +147,7 @@ dependencies {
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "org.robolectric:robolectric:4.7.3"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1"
testImplementation "com.google.truth:truth:$truth_version"
testImplementation "org.mockito:mockito-core:$mockito_version"

Expand Down
Binary file modified app/src/main/assets/tehro.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -29,7 +31,8 @@ fun TehScreen(
title: String,
color: Color = colorResource(id = R.color.layer_foreground),
fontFamily: FontFamily = LocaleHelper.properFontFamily,
action: Action? = null,
actions: List<Action> = emptyList(),
state: LazyListState = rememberLazyListState(),
content: LazyListScope.() -> Unit
) {

Expand All @@ -43,14 +46,15 @@ fun TehScreen(
title = title,
colorBackground = color,
fontFamily = fontFamily,
action = action
actions = actions
)

LazyColumn(
modifier = Modifier
.animateContentSize()
.fillMaxWidth()
.weight(1f),
state = state,
horizontalAlignment = Alignment.CenterHorizontally
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun TehTitle(
fontFamily: FontFamily = LocaleHelper.properFontFamily,
colorBackground: Color = colorResource(id = R.color.layer_foreground),
colorText: Color = colorBackground.getTextOnColor(),
action: Action? = null,
actions: List<Action> = emptyList(),
) {
Column(
modifier = modifier.fillMaxWidth()
Expand All @@ -66,15 +66,15 @@ fun TehTitle(
color = colorText,
textAlign = TextAlign.Start
)
action?.let {
actions.reversed().forEach { action ->
Icon(
modifier = action.iconModifier
.padding(grid())
.clip(CircleShape)
.clickable(onClick = action.onClick)
.padding(grid()),
imageVector = it.icon,
contentDescription = it.text,
imageVector = action.icon,
contentDescription = action.text,
tint = colorText
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ fun AboutScreen(
aboutViewModel: AboutViewModel
) {

val databaseInformation = aboutViewModel.databaseInformation.observeAsState()
val stats = aboutViewModel.stats.observeAsState()
val statsComplex = aboutViewModel.statsComplex.observeAsState()
val databaseInformation = aboutViewModel.databaseInformation.observeAsState(initial = Resource.Initial())
val stats = aboutViewModel.stats.observeAsState(initial = Resource.Initial())
val statsComplex = aboutViewModel.statsComplex.observeAsState(initial = Resource.Initial())

TehScreen(
title = stringResource(id = R.string.about),
Expand All @@ -61,7 +61,7 @@ fun AboutScreen(
item {
SegmentStats(
statsResource = stats.value,
databaseInformation = databaseInformation.value?.data
databaseInformation = databaseInformation.value.data
)
Spacer(modifier = Modifier.requiredHeight(grid(2)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import dev.yasan.metro.tehran.presentation.composable.screen.about.AboutScreen
*/
object AboutLinks {

const val URL_APP_GITHUB = "https://github.com/yasandev/tehro-android"
const val URL_DATABASE_GITHUB = "https://github.com/yasandev/tehro-database"
const val URL_APP_GITHUB = "https://github.com/yasan-org/tehro-android"
const val URL_DATABASE_GITHUB = "https://github.com/yasan-org/tehro-database"

const val URL_DEV_TELEGRAM = "https://t.me/YASANupdates"
const val URL_DEV_INSTAGRAM = "https://www.instagram.com/Yasandev"
const val URL_DEV_DISCORD = "https://discord.gg/8BQrfyA"
const val URL_DEV_MEDIUM = "https://yasandev.medium.com"
const val URL_DEV_TWITTER_EN = "https://twitter.com/YASAN"
const val URL_DEV_TWITTER_FA = "https://twitter.com/YASANfa"
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun AboutSegmentDev(fontFamily: FontFamily = LocaleHelper.properFontFamily) {

AboutLinkButton(
icon = AboutIcons.twitterIcon(),
url = if (LocaleHelper.isFarsi) AboutLinks.URL_DEV_TWITTER_FA else AboutLinks.URL_DEV_TWITTER_EN,
url = AboutLinks.URL_DEV_TWITTER_EN,
contentDescription = stringResource(
id = R.string.twitter
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.sharp.Info
import androidx.compose.material.icons.sharp.LocalBar
import androidx.compose.material.icons.sharp.Map
import androidx.compose.material.icons.sharp.Search
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -39,21 +41,25 @@ fun HomeScreen(
navController: NavController
) {

val lines = homeViewModel.lines.observeAsState()
val lines = homeViewModel.lines.observeAsState(initial = Resource.Initial())

if (lines.value is Resource.Initial) {
homeViewModel.loadLines()
LaunchedEffect(key1 = lines.value) {
if (lines.value is Resource.Initial) {
homeViewModel.loadLines()
}
}

TehScreen(
title = stringResource(id = R.string.app_name),
action = Action(
icon = TehroIcons.Search,
onClick = {
Navigator.navigateToSearch(navController = navController)
},
text = stringResource(id = R.string.search)
),
actions = listOf(
Action(
icon = TehroIcons.Search,
onClick = {
Navigator.navigateToSearch(navController = navController)
},
text = stringResource(id = R.string.search)
)
)
) {

when (lines.value) {
Expand All @@ -66,7 +72,7 @@ fun HomeScreen(
}
is Resource.Success -> {

val list = lines.value?.data ?: ArrayList()
val list = lines.value.data ?: ArrayList()

item {
Spacer(modifier = Modifier.requiredHeight(grid()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ fun LineScreen(
lineId: Int,
) {

val title = lineViewModel.title.observeAsState()
val lineColor = lineViewModel.lineColor.observeAsState()
val stations = lineViewModel.stations.observeAsState()
val title = lineViewModel.title.observeAsState(initial = "")
val lineColor = lineViewModel.lineColor.observeAsState(initial = Color.DarkGray)
val stations = lineViewModel.stations.observeAsState(initial = Resource.Initial())

rememberSystemUiController().setStatusBarColor(color = lineColor.value ?: Color.DarkGray)
rememberSystemUiController().setStatusBarColor(color = lineColor.value)

val orderAscending = rememberSaveable { mutableStateOf(true) }

Expand All @@ -66,15 +66,17 @@ fun LineScreen(
val buttonAngle by animateFloatAsState(if (orderAscending.value) 180f else 0f)

TehScreen(
title = title.value ?: "",
color = lineColor.value ?: Color.DarkGray,
action = Action(
iconModifier = Modifier.rotate(buttonAngle),
icon = TehroIcons.SwapVert,
text = "",
onClick = {
orderAscending.value = !orderAscending.value
}
title = title.value,
color = lineColor.value,
actions = listOf(
Action(
iconModifier = Modifier.rotate(buttonAngle),
icon = TehroIcons.SwapVert,
text = "",
onClick = {
orderAscending.value = !orderAscending.value
}
)
)
) {

Expand All @@ -88,7 +90,7 @@ fun LineScreen(
}
is Resource.Success -> {

val list = stations.value?.data ?: ArrayList()
val list = stations.value.data ?: ArrayList()

val stationCount = list.size

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private const val TAG = "MapScreen"
@Composable
fun MapScreen(mapViewModel: MapViewModel) {

val isLoaded = mapViewModel.isLoaded.observeAsState()
val isLoaded = mapViewModel.isLoaded.observeAsState(initial = false)

class MapEventListener : SubsamplingScaleImageView.OnImageEventListener {

Expand Down Expand Up @@ -94,7 +94,7 @@ fun MapScreen(mapViewModel: MapViewModel) {
)

androidx.compose.animation.AnimatedVisibility(
visible = isLoaded.value != true,
visible = !isLoaded.value,
enter = fadeIn(),
exit = fadeOut()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.navigation.NavController
import dev.yasan.kit.compose.foundation.grid
import dev.yasan.kit.core.Resource
import dev.yasan.metro.tehran.R
import dev.yasan.metro.tehran.model.misc.LaunchSource
import dev.yasan.metro.tehran.model.tehro.Line
Expand All @@ -45,10 +46,10 @@ fun SearchScreen(viewModel: SearchViewModel, navController: NavController) {
val queryState = rememberSaveable { mutableStateOf("") }
val groupEnabled = rememberSaveable { mutableStateOf(true) }

val results = viewModel.results.observeAsState()
val loading = viewModel.loading.observeAsState()
val results = viewModel.results.observeAsState(initial = Resource.Initial())
val loading = viewModel.loading.observeAsState(initial = true)

val resultsList = results.value?.data ?: emptyList()
val resultsList = results.value.data ?: emptyList()

TehScreen(title = stringResource(id = R.string.search)) {

Expand Down Expand Up @@ -79,7 +80,7 @@ fun SearchScreen(viewModel: SearchViewModel, navController: NavController) {

item {
AnimatedVisibility(
visible = loading.value == true,
visible = loading.value,
enter = expandVertically() + fadeIn(),
exit = shrinkVertically() + fadeOut()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun StationScreen(
stationViewModel.loadStation(stationId = stationId)
}

val stationResource = stationViewModel.station.observeAsState()
val stationResource = stationViewModel.station.observeAsState(initial = Resource.Initial())

when (stationResource.value) {
is Resource.Initial -> {
Expand All @@ -34,7 +34,7 @@ fun StationScreen(
}
}
is Resource.Success -> {
val station = stationResource.value!!.data!!
val station = stationResource.value.data!!
StationScreenSuccess(
station = station,
navController = navController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ fun StationScreenSuccess(
colorBorder = colorResource(id = R.color.text_title),
onClick = {

val uri = "geo:${station.locationLatitude},${station.locationLongitude}"
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("geo:${station.locationLatitude},${station.locationLongitude}?q=${station.locationLatitude},${station.locationLongitude}(${station.name})")
)

try {
context.startActivity(intent)
Expand Down
6 changes: 3 additions & 3 deletions fastlane/metadata/android/en-US/changelogs/232.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- The search button is now moved to the top of screen.
- Added the new option to reverse the order of stations on Line screen with a button.
- Fixed stations not being sorted by their position in line on Line screen.
- The search button is now moved to the top of the screen.
- Added the new option to reverse the order of stations on the Line screen with a button.
- Fixed stations not being sorted by their position in line on the Line screen.
- Added Android TV banner.
- Added Android TV (leanback) launcher support.
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/233.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Added almost all of the missing station locations.
- Improved how station locations are launched on supported map apps.
- Updated social links.

0 comments on commit 3f9f11d

Please sign in to comment.