Skip to content

Commit

Permalink
0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ztimms73 committed Dec 24, 2023
1 parent 086da0d commit 2e90993
Show file tree
Hide file tree
Showing 19 changed files with 297 additions and 251 deletions.
14 changes: 6 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
applicationId = "org.xtimms.ridebus"
minSdk = AndroidConfig.minSdk
targetSdk = AndroidConfig.targetSdk
versionCode = 3
versionCode = 4
versionName = "0.3"

buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
Expand Down Expand Up @@ -113,7 +113,7 @@ android {
}
}

packagingOptions {
packaging {
resources.excludes.addAll(
listOf(
"META-INF/DEPENDENCIES",
Expand All @@ -134,6 +134,7 @@ android {

buildFeatures {
viewBinding = true
buildConfig = true

// Disable some unused things
aidl = false
Expand Down Expand Up @@ -161,7 +162,7 @@ dependencies {

implementation(kotlin("reflect", version = BuildPluginsVersion.KOTLIN))

val coroutinesVersion = "1.6.4"
val coroutinesVersion = "1.7.3"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")

Expand Down Expand Up @@ -191,9 +192,6 @@ dependencies {
// Job scheduling
implementation("androidx.work:work-runtime-ktx:2.7.1")
implementation("com.google.guava:guava:31.1-android")
implementation(
"com.github.Koitharu.pausing-coroutine-dispatcher:pausing-coroutine-dispatcher:5213d53420"
)

// Network
implementation("com.squareup.retrofit2:retrofit:2.9.0")
Expand Down Expand Up @@ -233,7 +231,7 @@ dependencies {
implementation("io.github.reactivecircus.flowbinding:flowbinding-viewpager:$flowbindingVersion")

// UI libraries
implementation("com.google.android.material:material:1.8.0")
implementation("com.google.android.material:material:1.10.0")
implementation("com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533")
implementation("com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c8013533")
implementation("dev.chrisbanes.insetter:insetter:0.6.1")
Expand Down Expand Up @@ -292,7 +290,7 @@ tasks {
"-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=coil.annotation.ExperimentalCoilApi",
"-Xjvm-default=enable"
"-Xjvm-default=all"
)
}

Expand Down
28 changes: 26 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Keep extension's common dependencies
-keep,allowoptimization class org.xtimms.ridebus.** { public protected *; }
-keep,allowoptimization class androidx.preference.** { *; }
-keep,allowoptimization class kotlin.** { public protected *; }
Expand All @@ -11,6 +10,7 @@
-keep,allowoptimization class com.github.salomonbrys.kotson.** { public protected *; }
-keep,allowoptimization class com.squareup.duktape.** { public protected *; }
-keep,allowoptimization class uy.kohesive.injekt.** { public protected *; }
-keep,allowoptimization class com.yandex.** { public protected *; }

##---------------Begin: proguard configuration for RxJava 1.x ----------
-dontwarn sun.misc.**
Expand Down Expand Up @@ -61,4 +61,28 @@
-keepclassmembers class kotlinx.serialization.** {
<methods>;
}
##---------------End: proguard configuration for kotlinx.serialization ----------
##---------------End: proguard configuration for kotlinx.serialization ----------

# This is generated automatically by the Android Gradle plugin.
-dontwarn androidx.car.app.SurfaceCallback
-dontwarn androidx.car.app.SurfaceContainer
-dontwarn androidx.window.extensions.WindowExtensions
-dontwarn androidx.window.extensions.WindowExtensionsProvider
-dontwarn androidx.window.extensions.layout.DisplayFeature
-dontwarn androidx.window.extensions.layout.FoldingFeature
-dontwarn androidx.window.extensions.layout.WindowLayoutComponent
-dontwarn androidx.window.extensions.layout.WindowLayoutInfo
-dontwarn androidx.window.sidecar.SidecarDeviceState
-dontwarn androidx.window.sidecar.SidecarDisplayFeature
-dontwarn androidx.window.sidecar.SidecarInterface$SidecarCallback
-dontwarn androidx.window.sidecar.SidecarInterface
-dontwarn androidx.window.sidecar.SidecarProvider
-dontwarn androidx.window.sidecar.SidecarWindowLayoutInfo
-dontwarn com.oracle.svm.core.annotate.AutomaticFeature
-dontwarn com.oracle.svm.core.annotate.Delete
-dontwarn com.oracle.svm.core.annotate.Substitute
-dontwarn com.oracle.svm.core.annotate.TargetClass
-dontwarn com.oracle.svm.core.configure.ResourcesRegistry
-dontwarn org.graalvm.nativeimage.ImageSingletons
-dontwarn org.graalvm.nativeimage.hosted.Feature$BeforeAnalysisAccess
-dontwarn org.graalvm.nativeimage.hosted.Feature
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- For background jobs -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

Expand Down Expand Up @@ -47,10 +47,12 @@

<service
android:name=".data.updater.app.AppUpdateService"
android:foregroundServiceType="dataSync"
android:exported="false" />

<service
android:name=".data.updater.database.DatabaseUpdateService"
android:foregroundServiceType="dataSync"
android:exported="false" />

<meta-data
Expand Down
Binary file modified app/src/main/assets/database/ridebus_v3.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface ScheduleDao {
fun getArrivalTime(typeDay: Int, routeId: Int, stopId: Int): List<Timetable>

@Transaction
@Query("SELECT schedule._id AS id, schedule.route_id AS routeId, schedule.type_day AS typeDay, strftime('%H:%M', 'now', 'localtime', 'start of day', schedule.hour || ' hours', schedule.minute || ' minutes', routeStops.shift_hour || ' hours', routeStops.shift_minute || ' minutes') AS arrivalTime FROM schedule, routeStops WHERE (routeStops.route_id = :routeId AND schedule.route_id = :routeId AND routeStops.stop_id = :stopId AND schedule.type_day = :typeDay) ORDER BY schedule.hour, schedule.minute")
@Query("SELECT schedule._id AS id, schedule.route_id AS routeId, schedule.type_day AS typeDay, strftime('%H:%M', 'now', 'localtime', 'start of day', schedule.hour || ' hours', schedule.minute || ' minutes', routeStops.shift_hour || ' hours', routeStops.shift_minute || ' minutes') AS arrivalTime FROM schedule, routeStops WHERE (routeStops.route_id = :routeId AND schedule.route_id = :routeId AND routeStops.stop_id = :stopId AND schedule.type_day = :typeDay) ORDER BY schedule.hour, schedule.minute ASC")
fun observeArrivalTime(typeDay: Int, routeId: Int, stopId: Int): Flow<List<Timetable>>

@Query("SELECT DISTINCT hour FROM schedule where route_id = :routeId and type_day = :typeDay")
Expand Down
34 changes: 24 additions & 10 deletions app/src/main/java/org/xtimms/ridebus/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.Menu
import android.view.MenuItem
import android.view.ViewGroup
import androidx.core.animation.doOnEnd
import androidx.core.app.ActivityCompat
Expand Down Expand Up @@ -45,7 +47,6 @@ import org.xtimms.ridebus.ui.base.controller.*
import org.xtimms.ridebus.ui.favourite.FavouritesController
import org.xtimms.ridebus.ui.main.welcome.WelcomeDialogController
import org.xtimms.ridebus.ui.more.CriticalDatabaseUpdateDialogController
import org.xtimms.ridebus.ui.more.MoreController
import org.xtimms.ridebus.ui.more.NewScheduleDialogController
import org.xtimms.ridebus.ui.more.NewUpdateDialogController
import org.xtimms.ridebus.ui.routes.RoutesTabbedController
Expand Down Expand Up @@ -154,15 +155,6 @@ class MainActivity : BaseActivity() {
R.id.nav_routes -> router.setRoot(RoutesTabbedController(), id)
R.id.nav_stops -> router.setRoot(StopsController(), id)
R.id.nav_favourites -> router.setRoot(FavouritesController(), id)
R.id.nav_more -> router.setRoot(MoreController(), id)
}
} else if (!isHandlingShortcut) {
when (id) {
R.id.nav_more -> {
if (router.backstackSize == 1) {
router.pushController(SettingsMainController().withFadeTransaction())
}
}
}
}
true
Expand Down Expand Up @@ -241,6 +233,28 @@ class MainActivity : BaseActivity() {
.launchIn(lifecycleScope)
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
super.onCreateOptionsMenu(menu)
menuInflater.inflate(R.menu.main, menu)
return true
}

override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
if (menu == null) {
return false
}
menu.findItem(R.id.action_settings)?.isVisible = router.backstack.lastOrNull()?.controller is RootController
return super.onPrepareOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
R.id.action_settings -> {
router.pushController(SettingsMainController().withFadeTransaction())
true
}
else -> super.onOptionsItemSelected(item)
}

/**
* Sets custom splash screen exit animation on devices prior to Android 12.
*
Expand Down
150 changes: 0 additions & 150 deletions app/src/main/java/org/xtimms/ridebus/ui/more/AboutController.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ class MoreController :
iconTint = tintColor
onClick { router.pushController(SettingsMainController().withFadeTransaction()) }
}
preference {
iconRes = R.drawable.ic_info
iconTint = tintColor
titleRes = R.string.pref_category_about
onClick { router.pushController(AboutController().withFadeTransaction()) }
}
/*preference {
iconRes = R.drawable.ic_help
iconTint = tintColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ class SchedulePresenter(
val (hour, minute) = item.arrivalTime?.split(':') ?: continue
rows.getOrPut(hour.toInt()) { TreeSet() }.add(minute.toInt())
}
rows.entries.map {
ScheduleRow(it.key, it.value, time)
val sortedRows = rows.map {
val hour = it.key
val minutes = it.value
Pair(hour, minutes)
}.sortedBy { it.first }

sortedRows.map {
ScheduleRow(it.first, it.second, time)
}
}.flowOn(Dispatchers.Default)
.onEach { view?.setSchedule(it) }
Expand Down
Loading

0 comments on commit 2e90993

Please sign in to comment.