Author: Adam Pioterek <adam.pioterek@protonmail.ch>
back to logo & automatic timetable updates
app/src/main/AndroidManifest.xml | 2 app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt | 13 app/src/main/java/ml/adamsprogs/bimba/models/Timetable.kt | 9 + app/src/main/res/menu/menu_drawer.xml | 4 app/src/main/res/values-de/strings.xml | 16 - app/src/main/res/values-it/strings.xml | 15 - app/src/main/res/values-nl/strings.xml | 16 - app/src/main/res/values-pl/strings.xml | 16 - app/src/main/res/values/strings.xml | 17 - app/src/main/res/xml/pref_main.xml | 6
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 58ac9e4d29069e199be5ffbd848d746b75ee26e6..2ea63538f98ed731cd5d77c8791694fa2fc2c7cc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@<application android:allowBackup="true" - android:icon="@drawable/icon_dev" + android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt index a3bcc6e7dc5caf1b31a1d20b76a1062f914329b0..9320e22aef6596e5757970c7ba44d98b0c0afcf8 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt @@ -62,8 +62,6 @@ NetworkStateReceiver.init(this) getSuggestions() - warnTimetableValidity() - prepareFavourites() prepareListeners() @@ -77,9 +75,6 @@ when (item.itemId) { R.id.drawer_refresh -> { startDownloaderService(true) } - R.id.drawer_help -> { - startActivity(Intent(context, HelpActivity::class.java)) - } R.id.drawer_settings -> { startActivity(Intent(context, SettingsActivity::class.java)) } @@ -89,6 +84,8 @@ } drawerLayout.closeDrawer(drawerView) super.onOptionsItemSelected(item) } + + warnTimetableValidity() showValidityInDrawer() @@ -236,7 +233,9 @@ .setCancelable(true) .setMessage(message) .create().show() - //todo if days == -1 -> delete timetable + if (daysTillInvalid == -1) { + Timetable.delete(this) + } } private fun prepareFavourites() { @@ -271,7 +270,7 @@ receiver.addOnTimetableDownloadListener(context as MessageReceiver.OnTimetableDownloadListener) } private fun startDownloaderService(force: Boolean = false) { - if (getDefaultSharedPreferences(this).getBoolean("automatic timetable updates", false) or force) + if (getDefaultSharedPreferences(this).getBoolean(getString(R.string.key_timetable_automatic_update), false) or force) startService(Intent(context, TimetableDownloader::class.java)) } diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/Timetable.kt b/app/src/main/java/ml/adamsprogs/bimba/models/Timetable.kt index 3903ffbcec24fc67e2067efcf815c75e40d1545d..b3c50228730ad0aad928460bce6685a8500a04e3 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/models/Timetable.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/models/Timetable.kt @@ -47,6 +47,15 @@ null } this.timetable = timetable } + + fun delete(context: Context) { + val filesDir = context.getSecondaryExternalFilesDir() + val dbFile = File(filesDir, "timetable.db") + try { + dbFile.delete() + } catch (e: Exception) { + } + } } private var db: SQLiteDatabase? = null diff --git a/app/src/main/res/menu/menu_drawer.xml b/app/src/main/res/menu/menu_drawer.xml index b100a34f1b78517244b39dfb665156dc5f7a6b4d..3dbf30fa996dbd94345b8d176a0f110b1729033c 100644 --- a/app/src/main/res/menu/menu_drawer.xml +++ b/app/src/main/res/menu/menu_drawer.xml @@ -11,10 +11,10 @@ - android:id="@+id/drawer_refresh" android:icon="@drawable/ic_refresh" android:title="@string/refresh" /> - <item + <!--<item android:id="@+id/drawer_help" android:icon="@drawable/ic_help" - android:title="@string/help" /> + android:title="@string/help" />--> <item android:id="@+id/drawer_settings" android:icon="@drawable/ic_settings" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fc6cb018421f5b01bd650be84078c6b1522df076..b9385f070698ba94c13d54a19aa103dee644cf0b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,30 +42,18 @@
In %1$s minutes <string name="departure_in__plural_nominative">In %1$s minutes</string> <string name="home">Home</string> - <string name="refresh">Refresh</string> + <string name="refresh">Update timetable</string> <string name="help">Help</string> <string name="navigation_drawer_home_button" translatable="false">navigation drawer home button</string> <string name="navigation_drawer_refresh_button" translatable="false">navigation drawer refresh button</string> <string name="navigation_drawer_help_button" translatable="false">navigation drawer help button</string> <string name="title_activity_help">Help</string> <string name="help_text"> - "Why is there no timetable for Saturdays?\n\n" - - "Current official timetable will have been invalid by Saturday so it doesn’t contain times" - "for Saturdays.\n" - "Be sure to update timetable on Saturday at the latest.\n\n" - "Why a favourite card shows ‘No next departure’?\n\n" "Favourite cards contain times for today and tomorrow." "‘No next departure’ may happen when, e.g. there is no timetable for tomorrow and there" "are no more departures today.\n\n" - - "Today is Tuesday but it’s a holiday. Shouldn’t I look at Sundays timetable?\n\n" - - "Official timetable is especially prepared for holidays—it will show up as today (if" - "it’s Tuesday, it will be on ‘workdays’ tab).\n" - "Be sure to consult the messages on\nhttps://www.ztm.poznan.pl/en.\n\n" </string> <string name="departure_row_getting_departures">Getting departures…</string> <string name="valid_since">Valid since %1$s</string> @@ -90,6 +78,8 @@key_timetable_source_url <string name="title_timetable_source_url">Timetable source</string> <string name="title_activity_settings">Settings</string> <string name="settings">Settings</string> + <string name="key_timetable_automatic_update" translatable="false">key_timetable_automatic_update</string> + <string name="title_timetable_automatic_update">Automatic updates</string> <string name="Mon">Mon</string> <string name="Tue">Tue</string> @@ -98,4 +88,5 @@Thu <string name="Fri">Fri</string> <string name="Sat">Sat</string> <string name="Sun">Sun</string> + <string name="summary_timetable_automatic_update">Automatically check for and download timetable updates</string> </resources> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index bc754c49306b35a193dcb649178a347de04d8599..0d89712827a98db6c34e2a4b7faac7f0647f0956 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -33,30 +33,18 @@Zusammenfügen <string name="merge_favourites">Lieblingshaltestellen zusammenfügen</string> <string name="loading">Laden…</string> <string name="home">Startseite</string> - <string name="refresh">Erfrischen</string> + <string name="refresh">Fahrplan aktualisieren</string> <string name="help">Hilfe</string> <string name="title_activity_help">Hilfe</string> <string name="valid_since">Gilt seit %1$s</string> <string name="valid_till">Gilt bis %1$s</string> <string name="departure_row_getting_departures">Abfahrten sammeln…</string> <string name="help_text"> - "Warum gibt es keinen Fahrplan für Samstag?\n\n" - - "Der aktuelle offizielle Fahrplan wird bis Samstag ungültig sein also es enthält nicht den" - "Abfahrtszeiten für Samstag.\n" - "Sei sicher, den Fahrplan bis spätestens Samstag zu aktualisieren.\n\n" - "Warum Lieblingshaltestelle zeigt „Keine nächste Abfahrt“?\n\n" "Die Lieblingshaltestellen enthalten Abfahrtszeiten für heute und morgen." "„Keine nächste Abfahrt“ kann passieren, wenn es z.B. keinen Zeitplan für" "morgen gibt und heute keine Abfahrten mehr stattfinden.\n\n" - - "Heute ist Dienstag, aber es ist ein Feiertag. Soll ich nicht den Sonntags Fahrplan angucken?\n\n" - - "Der offizielle Fahrplan ist vorbereitet besonders für Feiertagen — es wird sich als" - "heute zeigen (wenn es Dienstag ist, es wird auf „Arbeitstage“ Karte sein).\n" - "Sei sicher, die Nachrichten auf\nhttps://www.ztm.poznan.pl/en\nkonsultieren.\n\n" </string> <string name="refreshing_cache">Cache wird aktualisiert. Es kann einige Zeit dauern…</string> <string name="today">Heute</string> @@ -80,4 +68,6 @@Do. <string name="Fri">Fr.</string> <string name="Sat">Sa.</string> <string name="Sun">So.</string> + <string name="title_timetable_automatic_update">Automatische Updates</string> + <string name="summary_timetable_automatic_update">Automatisch nach Fahrplanaktualisierungen suchen und diese herunterladen</string> </resources> diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 2f555258b4a51b199fde26df685ba07788e5bc20..16ed32fc1cb98d9bd718d396ff7d53ff47c4d766 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -36,25 +36,14 @@Nessuna partenza successiva <string name="action_merge">Unisci</string> <string name="merge_favourites">Unisci le favorite</string> <string name="loading">Caricamento in corso…</string> - <string name="refresh">Ricarica</string> + <string name="refresh">Aggiorna l’orario</string> <string name="departure_row_getting_departures">Ottenere le partenze…</string> <string name="help_text"> - "Perché non c’è nessun orario per il sabato?\n\n" - - "Attuale orario ufficiale sarà invalido entro sabato perciò non contiene ore per sabato.\n" - "Assicurati di aggiornare l’orario il sabato al più tardi\n\n" - "Perché un favorito mostra «Nessuna partenza successiva»?\n\n" "I favoriti contengono ore per oggi e domani." "«Nessuna partenza successiva» potrebbe succedere quando, ad esempio, non c’e orario per" "domani e non ci sono partenze oggi in più.\n\n" - - "Oggi è martedì però è un giorno festivo. Dovrei guardare l’orario per la domenica?\n\n" - - "L’orario ufficiale è preparato specialmente per giorni festivi – sarà mostrato come oggi" - "(se è martedì, sarà nella scheda «giorni di lavoro»).\n" - "Assicurati di consultare le notifiche su\nhttps://www.ztm.poznan.pl/en.\n\n" </string> <string name="refreshing_cache">Cache sta essendo aggiornato. Può richiedere un certo tempo…</string> <string name="today">Oggi</string> @@ -78,4 +67,6 @@gio <string name="Fri">ven</string> <string name="Sat">sab</string> <string name="Sun">dom</string> + <string name="summary_timetable_automatic_update">Controlla e scarica automaticamente gli aggiornamenti dell’orario</string> + <string name="title_timetable_automatic_update">Aggiornamenti automatici</string> </resources> diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 82150b353f9a2b6c74446ff0d4415c6b8b4a12db..b221b994f403382f9f5d11fb7aeb7cd93a3dbf09 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -33,27 +33,15 @@Over %1$s minuten <string name="departure_in__plural_nominative">Over %1$s minuten</string> <string name="home">Startpagina</string> - <string name="refresh">Verversen</string> + <string name="refresh">Dienstregeling bijwerken</string> <string name="help">Hulp</string> <string name="title_activity_help">Hulp</string> <string name="help_text"> - "Waarom is er geen zaterdagdienstregeling?\n\n" - - "De huidige dienstregeling zal zaterdag niet meer kloppen; daarom bevat deze geen tijden" - "voor zaterdag.\n" - "Zorg ervoor dat je uiterlijk zaterdag de dienstregeling bijwerkt.\n\n" - "Waarom toont een favoriet ‘Geen vertrektijden’?\n\n" "Favorieten tonen tijden voor vandaag en morgen." "‘Geen vertrektijden’ kan worden getoond als er bijv. geen dienstregeling voor morgen is en" "er vandaag geen voertuigen meer vertrekken.\n\n" - - "Het is vandaag niet alleen dinsdag, maar ook een feestdag. Moet ik niet naar de zondagsdienstregeling kijken?\n\n" - - "De dienstregeling is voorbereid op feestdagen; deze zal worden weergegeven als vandaag (als" - "het dinsdag is, dan zal deze zich bevinden op het tabblad ‘werkdagen’).\n" - "Lees ook de berichten op\nhttps://www.ztm.poznan.pl/en.\n\n" </string> <string name="departure_row_getting_departures">Bezig met ophalen van vertrektijden…</string> <string name="valid_since">Ingegaan op %1$s</string> @@ -81,4 +69,6 @@do <string name="Fri">vr</string> <string name="Sat">za</string> <string name="Sun">zo</string> + <string name="title_timetable_automatic_update">Automatische updates</string> + <string name="summary_timetable_automatic_update">Automatisch controleren en download dienstregeling updates</string> </resources> diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ce9634e0554f906aa47db97f48b47415abfe3742..b7e12ec5d2b6da0c24c679dab4db23edda1e645b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -33,27 +33,15 @@Za %1$s minutę <string name="departure_in__plural_genitive">Za %1$s minut</string> <string name="departure_in__plural_nominative">Za %1$s minuty</string> <string name="home">Strona główna</string> - <string name="refresh">Odśwież</string> + <string name="refresh">Zaktualizuj rozkład</string> <string name="help">Pomoc</string> <string name="title_activity_help">Pomoc</string> <string name="help_text"> - "Dlaczego nie ma rozkładu na sobotę?\n\n" - - "Aktualny oficjalny rozkład będzie nieważny przed sobotą, więc nie zawiera czasów dla" - "soboty.\n" - "Pamiętaj, aby zaktualizować rozkład najpóźniej w sobotę.\n\n" - "Dlaczego ulubiony pokazuje „Brak następnego odjazdu”?\n\n" "Ulubione zawierają czasy dla dzisiaj i jutra." "„Brak następnego odjazdu” może się wydarzyć, np. gdy nie ma rozkładu na jutro, a dzisiaj" "nie ma już odjazdów.\n\n" - - "Dziś jest wtorek, ale jest święto. Nie powinienem patrzeć na rozkład dla niedzieli?\n\n" - - "Oficjalny rozkład jest specjalnie przygotowywany na święta — będzie widoczny w dzisiejszej" - "zakładce (jeśli jest wtorek, to w „dni robocze”).\n" - "Pamiętaj, aby sprawdzić aktualności na\nhttps://www.ztm.poznan.pl.\n\n" </string> <string name="departure_row_getting_departures">Zbieranie odjazdów…</string> <string name="valid_since">Ważny od %1$s</string> @@ -80,4 +68,6 @@czw. <string name="Fri">pt.</string> <string name="Sat">sob.</string> <string name="Sun">niedz.</string> + <string name="summary_timetable_automatic_update">Automatycznie sprawdzaj i pobieraj aktualizacje rozkładu</string> + <string name="title_timetable_automatic_update">Automatyczne aktualizacje</string> </resources> \ No newline at end of file diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index edbdd769a5229ecc162ac8bc3b128c86a91dbe4d..e35091e5b4688366446865e6123a4cfe880fd70b 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -11,8 +11,8 @@ <!-- todo reset source --> <SwitchPreference android:defaultValue="false" - android:key="key_timetable_automatic_update" - android:summary="Automatically check for and download timetable updates" - android:title="Automatic updates" /> + android:key="@string/key_timetable_automatic_update" + android:summary="@string/summary_timetable_automatic_update" + android:title="@string/title_timetable_automatic_update" /> </PreferenceCategory> </PreferenceScreen>