diff --git a/app/src/androidTest/java/ml/adamsprogs/bimba/ExampleInstrumentedTest.java b/app/src/androidTest/java/ml/adamsprogs/bimba/ExampleInstrumentedTest.java
deleted file mode 100644
index cef03f892c551316d036664d501ddd0933ba8383..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/ml/adamsprogs/bimba/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ml.adamsprogs.bimba;
-
-import android.content.Context;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("ml.adamsprogs.bimba", appContext.getPackageName());
- }
-}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e0b120550519b6a66af16dd4c18b7fe0c5606fcc..25e36bf5433aefd3a374503d0e5d22067650e1ad 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
package="ml.adamsprogs.bimba"
android:installLocation="auto">
@@ -7,12 +8,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
- android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
- android:label="@string/app_name"
android:supportsRtl="true"
- android:theme="@style/AppTheme">
+ android:theme="@style/AppTheme"
+ tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activities.DashActivity" />
<service
@@ -33,15 +34,11 @@ android:name=".activities.SettingsActivity"
android:label="@string/title_activity_settings"
android:parentActivityName=".activities.DashActivity"
- android:theme="@style/AppTheme" >
+ android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ml.adamsprogs.bimba.activities.DashActivity" />
</activity>
- <activity
- android:name=".activities.HelpActivity"
- android:label="@string/title_activity_help"
- android:theme="@style/AppTheme" />
<service
android:name=".datasources.VmService"
diff --git a/app/src/main/java/ml/adamsprogs/bimba/NetworkStateReceiver.kt b/app/src/main/java/ml/adamsprogs/bimba/NetworkStateReceiver.kt
index 2acd1e1eb9dbb95db986e6907c6e07db549c9792..770ba13101e61f4ccd213248bb2af9aadc0f4874 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/NetworkStateReceiver.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/NetworkStateReceiver.kt
@@ -24,14 +24,6 @@ }
}
}
- fun addOnConnectivityChangeListener(listener: OnConnectivityChangeListener) {
- onConnectivityChangeListeners.add(listener)
- }
-
- fun removeOnConnectivityChangeListener(listener: OnConnectivityChangeListener) {
- onConnectivityChangeListeners.remove(listener)
- }
-
interface OnConnectivityChangeListener {
fun onConnectivityChange(connected: Boolean)
}
diff --git a/app/src/main/java/ml/adamsprogs/bimba/NotificationChannels.kt b/app/src/main/java/ml/adamsprogs/bimba/NotificationChannels.kt
index 009de4ed616680e7e1b7cc6c91aa152330e3cb75..738003153a01f7d7753f888009f26268299a5f78 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/NotificationChannels.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/NotificationChannels.kt
@@ -8,7 +8,7 @@
class NotificationChannels {
companion object {
- val CHANNEL_UPDATES = "updates"
+ const val CHANNEL_UPDATES = "updates"
@RequiresApi(Build.VERSION_CODES.O)
fun makeChannel(id: String, name: String, manager: NotificationManager) {
diff --git a/app/src/main/java/ml/adamsprogs/bimba/ProviderProxy.kt b/app/src/main/java/ml/adamsprogs/bimba/ProviderProxy.kt
index cb45d2c150fc033ecc5e182c06d5a0db0a967280..59fb99a4f9c56b6927f3996146904d74b070883e 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/ProviderProxy.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/ProviderProxy.kt
@@ -1,11 +1,17 @@
package ml.adamsprogs.bimba
-import android.content.*
+import android.content.Context
+import android.content.Intent
import kotlinx.coroutines.*
import kotlinx.coroutines.android.Main
-import ml.adamsprogs.bimba.datasources.*
-import ml.adamsprogs.bimba.models.*
-import ml.adamsprogs.bimba.models.suggestions.*
+import ml.adamsprogs.bimba.datasources.VmClient
+import ml.adamsprogs.bimba.datasources.VmService
+import ml.adamsprogs.bimba.models.Departure
+import ml.adamsprogs.bimba.models.Plate
+import ml.adamsprogs.bimba.models.StopSegment
+import ml.adamsprogs.bimba.models.Timetable
+import ml.adamsprogs.bimba.models.suggestions.GtfsSuggestion
+import ml.adamsprogs.bimba.models.suggestions.StopSuggestion
import java.util.*
import kotlin.collections.HashMap
@@ -24,13 +30,13 @@ const val MODE_VM = "mode_vm"
}
fun getSuggestions(query: String = "", callback: (List<GtfsSuggestion>) -> Unit) {
- launch(Dispatchers.Main, CoroutineStart.DEFAULT, null, {
- val filtered = withContext(Dispatchers.Default) {
- suggestions = getStopSuggestions(query) //+ getLineSuggestions(query) //todo<p:v+1> + bike stations, train stations, &c
- filterSuggestions(query)
+ GlobalScope.launch {
+ suggestions = getStopSuggestions(query) //+ getLineSuggestions(query) //todo<p:v+1> + bike stations, train stations, &c
+ val filtered = filterSuggestions(query)
+ launch(Dispatchers.Main) {
+ callback(filtered)
}
- callback(filtered)
- })
+ }
}
private suspend fun getStopSuggestions(query: String): List<StopSuggestion> {
@@ -65,18 +71,18 @@ return result
}
fun getSheds(name: String, callback: (Map<String, Set<String>>) -> Unit) {
- launch(Dispatchers.Main) {
- val sheds = withContext(Dispatchers.Default) {
- val vmSheds = vmClient.getSheds(name)
+ GlobalScope.launch {
+ val vmSheds = vmClient.getSheds(name)
- if (vmSheds.isEmpty() and !timetable.isEmpty()) {
- timetable.getHeadlinesForStop(name)
- } else {
- vmSheds
- }
+ val sheds = if (vmSheds.isEmpty() and !timetable.isEmpty()) {
+ timetable.getHeadlinesForStop(name)
+ } else {
+ vmSheds
}
- callback(sheds)
+ launch(Dispatchers.Main) {
+ callback(sheds)
+ }
}
}
@@ -104,13 +110,13 @@ return uuid
}
private fun constructSegmentDepartures(stopSegments: Set<StopSegment>): Deferred<Map<String, List<Departure>>> {
- return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT, null, {
+ return GlobalScope.async {
if (timetable.isEmpty())
emptyMap()
else {
timetable.getStopDeparturesBySegments(stopSegments)
}
- })
+ }
}
private fun filterDepartures(departures: Map<String, List<Departure>>): List<Departure> {
@@ -161,10 +167,8 @@
}
fun fillStopSegment(stopSegment: StopSegment, callback: (StopSegment?) -> Unit) {
- launch(Dispatchers.Main) {
- withContext(Dispatchers.Default) {
- callback(fillStopSegment(stopSegment))
- }
+ GlobalScope.launch {
+ callback(fillStopSegment(stopSegment))
}
}
@@ -179,10 +183,8 @@ timetable.getHeadlinesForStopCode(stopSegment.stop)
}
fun getStopName(stopCode: String, callback: (String?) -> Unit) {
- launch(Dispatchers.Main) {
- withContext(Dispatchers.Default) {
- callback(getStopName(stopCode))
- }
+ GlobalScope.launch {
+ callback(getStopName(stopCode))
}
}
@@ -216,13 +218,13 @@ private var cache: Deferred