Compare commits

...

7 Commits
1.4.4 ... 1.4.5

Author SHA1 Message Date
johan12345
c0b4c56eda Release 1.4.5 2023-01-20 20:10:57 +01:00
Hosted Weblate
9587ee948d Update translation files
Updated by "Squash Git commits" hook in Weblate.

Translated using Weblate (Norwegian Bokmål)

Currently translated at 83.3% (30 of 36 strings)

Co-authored-by: Allan Nordhøy <epost@anotheragency.no>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/evmap/android-google/
Translate-URL: https://hosted.weblate.org/projects/evmap/android-google/nb_NO/
Translation: EVMap/Android (strings specific to Google Play variant)
2023-01-20 19:13:16 +01:00
johan12345
890eec4419 FilterFragment: add button to reset current settings 2023-01-20 19:12:52 +01:00
johan12345
c972c871d4 add icons to filter popup menu 2023-01-20 18:38:06 +01:00
johan12345
e4da902430 GooglePlacesAutocompleteProvider: fix crash on network error 2023-01-19 22:28:13 +01:00
johan12345
7a5d4b4107 fix NPE 2023-01-08 12:48:23 +01:00
johan12345
80642b1731 fix infinite recursion in Utils.max 2023-01-08 12:45:31 +01:00
18 changed files with 134 additions and 18 deletions

View File

@@ -21,8 +21,8 @@ android {
minSdkVersion 21
targetSdkVersion 33
// NOTE: always increase versionCode by 2 since automotive flavor uses versionCode + 1
versionCode 156
versionName "1.4.4"
versionCode 158
versionName "1.4.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs supportedLocales.split(",")

View File

@@ -148,6 +148,7 @@ class PlaceSearchScreen(ctx: CarContext, val session: EVMapSession) : Screen(ctx
}
private suspend fun loadNewList(query: String) {
val location = location?.let { LatLng.fromLocation(it) }
for (provider in providers) {
try {
recentResults.clear()
@@ -161,7 +162,7 @@ class PlaceSearchScreen(ctx: CarContext, val session: EVMapSession) : Screen(ctx
}
recentResults.addAll(recentPlaces)
resultList =
recentPlaces.map { it.asAutocompletePlace(LatLng.fromLocation(location)) }
recentPlaces.map { it.asAutocompletePlace(location) }
invalidate()
// if we already have enough results or the query is short, stop here
@@ -170,7 +171,7 @@ class PlaceSearchScreen(ctx: CarContext, val session: EVMapSession) : Screen(ctx
// then search online
val recentIds = recentPlaces.map { it.id }
resultList = withContext(Dispatchers.IO) {
(resultList!! + provider.autocomplete(query, LatLng.fromLocation(location))
(resultList!! + provider.autocomplete(query, location)
.filter { !recentIds.contains(it.id) }).take(maxItems)
}
invalidate()

View File

@@ -7,6 +7,7 @@ import android.text.style.StyleSpan
import com.car2go.maps.google.adapter.AnyMapAdapter
import com.car2go.maps.util.SphericalUtil
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.CommonStatusCodes
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.LatLngBounds
import com.google.android.gms.tasks.Tasks.await
@@ -19,6 +20,7 @@ import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRe
import com.google.android.libraries.places.api.net.PlacesStatusCodes
import kotlinx.coroutines.tasks.await
import net.vonforst.evmap.R
import java.io.IOException
import java.util.concurrent.ExecutionException
import kotlin.math.sqrt
@@ -58,6 +60,13 @@ class GooglePlacesAutocompleteProvider(val context: Context) : AutocompleteProvi
if (cause is ApiException) {
if (cause.statusCode == PlacesStatusCodes.OVER_QUERY_LIMIT) {
throw ApiUnavailableException()
} else if (cause.statusCode in listOf(
CommonStatusCodes.NETWORK_ERROR,
CommonStatusCodes.TIMEOUT, CommonStatusCodes.RECONNECTION_TIMED_OUT,
CommonStatusCodes.RECONNECTION_TIMED_OUT_DURING_UPDATE
)
) {
throw IOException(cause)
}
}
throw e

View File

@@ -36,4 +36,6 @@
<string name="sounds_cool">den er grei</string>
<string name="auto_chargers_ahead">Kun ladere i kjøreretningen</string>
<string name="loading">Laster inn …</string>
<string name="auto_multipage_goto">Side %d</string>
<string name="auto_multipage">(%d/%d)</string>
</resources>

View File

@@ -72,7 +72,7 @@ fun max(a: Int?, b: Int?): Int? {
* otherwise the non-null value or null
*/
return if (a != null && b != null) {
max(a, b)
kotlin.math.max(a, b)
} else {
a ?: b
}

View File

@@ -98,6 +98,12 @@ class FilterFragment : Fragment(), MenuProvider {
saveProfile()
true
}
R.id.menu_reset -> {
lifecycleScope.launch {
vm.resetValues()
}
true
}
else -> false
}
}

View File

@@ -1189,6 +1189,7 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
)
popup.menuInflater.inflate(R.menu.popup_filter, popup.menu)
MenuCompat.setGroupDividerEnabled(popup.menu, true)
popup.setForceShowIcon(true)
popup.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_edit_filters -> {

View File

@@ -1,29 +1,49 @@
package net.vonforst.evmap.storage
import androidx.lifecycle.liveData
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.room.*
import net.vonforst.evmap.model.*
@Dao
abstract class FilterValueDao {
@Query("SELECT * FROM booleanfiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract suspend fun getBooleanFilterValues(
protected abstract suspend fun getBooleanFilterValuesAsync(
profile: Long,
dataSource: String
): List<BooleanFilterValue>
@Query("SELECT * FROM multiplechoicefiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract suspend fun getMultipleChoiceFilterValues(
protected abstract suspend fun getMultipleChoiceFilterValuesAsync(
profile: Long,
dataSource: String
): List<MultipleChoiceFilterValue>
@Query("SELECT * FROM sliderfiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract suspend fun getSliderFilterValues(
protected abstract suspend fun getSliderFilterValuesAsync(
profile: Long,
dataSource: String
): List<SliderFilterValue>
@Query("SELECT * FROM booleanfiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract fun getBooleanFilterValues(
profile: Long,
dataSource: String
): LiveData<List<BooleanFilterValue>>
@Query("SELECT * FROM multiplechoicefiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract fun getMultipleChoiceFilterValues(
profile: Long,
dataSource: String
): LiveData<List<MultipleChoiceFilterValue>>
@Query("SELECT * FROM sliderfiltervalue WHERE profile = :profile AND dataSource = :dataSource")
protected abstract fun getSliderFilterValues(
profile: Long,
dataSource: String
): LiveData<List<SliderFilterValue>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
protected abstract suspend fun insert(vararg values: BooleanFilterValue)
@@ -58,15 +78,32 @@ abstract class FilterValueDao {
if (filterStatus == FILTERS_DISABLED || filterStatus == FILTERS_FAVORITES) {
emptyList()
} else {
getBooleanFilterValues(filterStatus, dataSource) +
getMultipleChoiceFilterValues(filterStatus, dataSource) +
getSliderFilterValues(filterStatus, dataSource)
getBooleanFilterValuesAsync(filterStatus, dataSource) +
getMultipleChoiceFilterValuesAsync(filterStatus, dataSource) +
getSliderFilterValuesAsync(filterStatus, dataSource)
}
open fun getFilterValues(filterStatus: Long, dataSource: String) = liveData {
emit(null)
emit(getFilterValuesAsync(filterStatus, dataSource))
}
open fun getFilterValues(filterStatus: Long, dataSource: String): LiveData<List<FilterValue>?> =
if (filterStatus == FILTERS_DISABLED || filterStatus == FILTERS_FAVORITES) {
MutableLiveData(emptyList())
} else {
MediatorLiveData<List<FilterValue>?>().apply {
value = null
val sources = listOf(
getBooleanFilterValues(filterStatus, dataSource),
getMultipleChoiceFilterValues(filterStatus, dataSource),
getSliderFilterValues(filterStatus, dataSource)
)
for (source in sources) {
addSource(source) {
val values = sources.map { it.value }
if (values.all { it != null }) {
value = values.filterNotNull().flatten()
}
}
}
}
}
@Transaction
open suspend fun insert(vararg values: FilterValue) {

View File

@@ -92,4 +92,8 @@ class FilterViewModel(application: Application) : AndroidViewModel(application)
prefs.filterStatus = FILTERS_DISABLED
}
}
suspend fun resetValues() {
db.filterValueDao().deleteFilterValuesForProfile(FILTERS_CUSTOM, prefs.dataSource)
}
}

View File

@@ -0,0 +1,10 @@
<vector android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M10.83,8H21V6H8.83L10.83,8zM15.83,13H18v-2h-4.17L15.83,13zM14,16.83V18h-4v-2h3.17l-3,-3H6v-2h2.17l-3,-3H3V6h0.17L1.39,4.22l1.41,-1.41l18.38,18.38l-1.41,1.41L14,16.83z" />
</vector>

View File

@@ -0,0 +1,10 @@
<vector android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M3,10h11v2H3V10zM3,8h11V6H3V8zM3,16h7v-2H3V16zM18.01,12.87l0.71,-0.71c0.39,-0.39 1.02,-0.39 1.41,0l0.71,0.71c0.39,0.39 0.39,1.02 0,1.41l-0.71,0.71L18.01,12.87zM17.3,13.58l-5.3,5.3V21h2.12l5.3,-5.3L17.3,13.58z" />
</vector>

View File

@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_reset"
android:title="@string/menu_reset"
android:icon="@drawable/ic_filter_no"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_save_profile"
android:title="@string/menu_save_profile"

View File

@@ -8,9 +8,11 @@
<item
android:id="@+id/menu_edit_filters"
android:title="@string/menu_edit_filters"
android:menuCategory="secondary" />
android:menuCategory="secondary"
android:icon="@drawable/ic_edit" />
<item
android:id="@+id/menu_manage_filter_profiles"
android:title="@string/menu_manage_filter_profiles"
android:menuCategory="secondary" />
android:menuCategory="secondary"
android:icon="@drawable/ic_manage_filter_profiles" />
</menu>

View File

@@ -143,6 +143,7 @@
<string name="category_caravan_site">Wohnmobilstellplatz</string>
<string name="menu_apply">Filter anwenden</string>
<string name="menu_save_profile">Als Profil speichern</string>
<string name="menu_reset">Filter zurücksetzen</string>
<string name="no_filters">Keine Filter</string>
<string name="filter_custom">Verändertes Filterprofil</string>
<string name="filter_favorites">Favoriten</string>

View File

@@ -284,4 +284,16 @@
<string name="pref_prediction_enabled">Vis bruksprognoser</string>
<string name="pref_prediction_enabled_summary">for støttede ladere
\n(foreløpig kun for likestrøm i Tyskland)</string>
<string name="chargeprice_price_not_available">Pris ikke tilgjengelig</string>
<string name="developer_mode_disabled">Utviklermodus avslått</string>
<string name="gps">GPS</string>
<string name="compass">Kompass</string>
<string name="pref_applink_associate">Åpne støttede lenker</string>
<string name="pref_applink_associate_summary">fra goingelectric.de og openchargemap.org</string>
<string name="chargeprice_header_other_tariffs">Andre ladeabonnementer</string>
<string name="disable_developer_mode">Skru av utviklermodus</string>
<string name="chargeprice_header_my_tariffs">Mine ladeabonnementer</string>
<string name="developer_options">Utvikleralternativer</string>
<string name="data_source_switched_to">Datakilde byttet til %s</string>
<string name="developer_mode_enabled">Utviklermodus påslått</string>
</resources>

View File

@@ -142,6 +142,7 @@
<string name="category_caravan_site">Caravan site</string>
<string name="menu_apply">Apply filters</string>
<string name="menu_save_profile">Save as profile</string>
<string name="menu_reset">Reset filter settings</string>
<string name="no_filters">No filters</string>
<string name="filter_custom">Modified filter</string>
<string name="filter_favorites">Favorites</string>

View File

@@ -0,0 +1,7 @@
Verbesserungen:
- Neuer Knopf zum Zurücksetzen der Filtereinstellungen
- Filtermenü mit neuen Icons
- Übersetzungen aktualisiert
Fehler behoben:
- Abstürze behoben

View File

@@ -0,0 +1,7 @@
Improvements:
- New button to reset filter setting
- Filter menu with new icons
- Updated translations
Bugfixes:
- Fixed crashes