diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/GeocodingHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/GeocodingHandler.kt index 17ced0c0b..ddb100edd 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/GeocodingHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/GeocodingHandler.kt @@ -9,6 +9,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import java.io.IOException import java.util.* // as of 2021/03/10, geocoding packages exist but: @@ -50,6 +51,10 @@ class GeocodingHandler(private val context: Context) : MethodCallHandler { val addresses = try { geocoder!!.getFromLocation(latitude, longitude, maxResults) ?: ArrayList() + } catch (e: IOException) { + // `grpc failed`, etc. + result.error("getAddress-network", "failed to get address because of network issues", e.message) + return } catch (e: Exception) { result.error("getAddress-exception", "failed to get address", e.message) return diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt b/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt index 21b61b732..46c289c3b 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt @@ -80,6 +80,14 @@ object StorageUtils { return pathSteps.iterator() } + private fun appSpecificVolumePath(file: File?): String? { + file ?: return null + val appSpecificPath = file.absolutePath + val relativePathStartIndex = appSpecificPath.indexOf("Android/data") + if (relativePathStartIndex < 0) return null + return appSpecificPath.substring(0, relativePathStartIndex) + } + private fun findPrimaryVolumePath(context: Context): String? { // we want: // /storage/emulated/0/ @@ -87,10 +95,7 @@ object StorageUtils { // /storage/emulated/0 // `context.getExternalFilesDir(null)` yields: // /storage/emulated/0/Android/data/{package_name}/files - return context.getExternalFilesDir(null)?.let { - val appSpecificPath = it.absolutePath - return appSpecificPath.substring(0, appSpecificPath.indexOf("Android/data")) - } + return appSpecificVolumePath(context.getExternalFilesDir(null)) } private fun findVolumePaths(context: Context): Array { @@ -119,11 +124,7 @@ object StorageUtils { } } } while (!validFiles) - for (file in files) { - val appSpecificAbsolutePath = file.absolutePath - val emulatedRootPath = appSpecificAbsolutePath.substring(0, appSpecificAbsolutePath.indexOf("Android/data")) - paths.add(emulatedRootPath) - } + paths.addAll(files.mapNotNull(::appSpecificVolumePath)) } else { // Primary physical SD-CARD (not emulated) val rawExternalStorage = System.getenv("EXTERNAL_STORAGE") ?: "" diff --git a/lib/services/geocoding_service.dart b/lib/services/geocoding_service.dart index d411dfea2..09a9f4d96 100644 --- a/lib/services/geocoding_service.dart +++ b/lib/services/geocoding_service.dart @@ -22,7 +22,7 @@ class GeocodingService { }); return (result as List).cast().map((map) => Address.fromMap(map)).toList(); } on PlatformException catch (e, stack) { - if (e.code != 'getAddress-empty') { + if (e.code != 'getAddress-empty' && e.code != 'getAddress-network') { await reportService.recordError(e, stack); } } diff --git a/lib/widgets/about/bug_report.dart b/lib/widgets/about/bug_report.dart index cee2b94aa..e2112718e 100644 --- a/lib/widgets/about/bug_report.dart +++ b/lib/widgets/about/bug_report.dart @@ -4,6 +4,7 @@ import 'dart:typed_data'; import 'package:aves/app_flavor.dart'; import 'package:aves/flutter_version.dart'; +import 'package:aves/model/settings/settings.dart'; import 'package:aves/ref/mime_types.dart'; import 'package:aves/services/common/services.dart'; import 'package:aves/theme/durations.dart'; @@ -71,16 +72,33 @@ class _BugReportState extends State with FeedbackMixin { final info = snapshot.data; if (info == null) return const SizedBox(); return Container( - padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.grey.shade800, - border: Border.all( - color: Colors.white, - ), - borderRadius: const BorderRadius.all(Radius.circular(8)), + decoration: BoxDecoration( + color: Colors.grey.shade800, + border: Border.all( + color: Colors.white, ), - margin: const EdgeInsets.symmetric(vertical: 8), - child: SelectableText(info)); + borderRadius: const BorderRadius.all(Radius.circular(8)), + ), + constraints: const BoxConstraints(maxHeight: 100), + margin: const EdgeInsets.symmetric(vertical: 8), + child: Theme( + data: Theme.of(context).copyWith( + scrollbarTheme: const ScrollbarThemeData( + isAlwaysShown: true, + radius: Radius.circular(16), + crossAxisMargin: 6, + mainAxisMargin: 6, + interactive: true, + ), + ), + child: Scrollbar( + child: Padding( + padding: const EdgeInsetsDirectional.only(start: 8, end: 16), + child: SelectableText(info), + ), + ), + ), + ); }, ), _buildStep(3, l10n.aboutBugReportInstruction, l10n.aboutBugReportButton, _goToGithub), @@ -136,6 +154,8 @@ class _BugReportState extends State with FeedbackMixin { 'Android build: ${androidInfo.display}', 'Device: ${androidInfo.manufacturer} ${androidInfo.model}', 'Google Play services: ${hasPlayServices ? 'ready' : 'not available'}', + 'System locales: ${WidgetsBinding.instance!.window.locales.join(', ')}', + 'Aves locale: ${settings.locale} -> ${settings.appliedLocale}', ].join('\n'); }