Skip to content

Commit

Permalink
1462: update kotlin android plugin, set kotlinOptions to jvm target, …
Browse files Browse the repository at this point in the history
…add workaround to reload map page if it comes to foreground
  • Loading branch information
f1sh1918 committed Jun 25, 2024
1 parent c5da615 commit 5634430
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
4 changes: 4 additions & 0 deletions frontend/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ ext.setupVariant = { variant, buildConfigName ->
android {
compileSdkVersion 34

kotlinOptions {
jvmTarget=JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.1" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

include ":app"
24 changes: 12 additions & 12 deletions frontend/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ PODS:
- GoogleToolboxForMac/Defines (= 2.3.2)
- "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)"
- "GoogleToolboxForMac/NSString+URLArguments (2.3.2)"
- GoogleUtilities/Environment (7.13.0):
- GoogleUtilities/Environment (7.13.3):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.13.0):
- GoogleUtilities/Logger (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.0)
- GoogleUtilities/UserDefaults (7.13.0):
- GoogleUtilities/Privacy (7.13.3)
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- GoogleUtilitiesComponents (1.1.0):
- GoogleUtilities/Logger
- GTMSessionFetcher/Core (2.3.0)
- MapLibre (5.14.0-pre3)
- MapLibre (6.5.0)
- maplibre_gl (0.0.1):
- Flutter
- MapLibre (= 5.14.0-pre3)
- MapLibre (= 6.5.0)
- MLImage (1.0.0-beta4)
- MLKitBarcodeScanning (3.0.0):
- MLKitCommon (~> 9.0)
Expand Down Expand Up @@ -83,7 +83,7 @@ PODS:
- permission_handler_apple (9.3.0):
- Flutter
- PromisesObjC (2.4.0)
- ReachabilitySwift (5.2.1)
- ReachabilitySwift (5.2.3)
- Sentry/HybridSDK (8.21.0):
- SentryPrivate (= 8.21.0)
- sentry_flutter (0.0.1):
Expand Down Expand Up @@ -172,11 +172,11 @@ SPEC CHECKSUMS:
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e
GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
MapLibre: 620fc933c1d6029b33738c905c1490d024e5d4ef
maplibre_gl: a2efec727dd340e4c65e26d2b03b584f14881fd9
MapLibre: 0ebfa9329d313cec8bf0a5ba5a336a1dc903785e
maplibre_gl: 943a491fffb3337c1b9de57fd377206d18c16e34
MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b
MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505
MLKitCommon: c1b791c3e667091918d91bda4bba69a91011e390
Expand All @@ -187,7 +187,7 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
ReachabilitySwift: 5ae15e16814b5f9ef568963fb2c87aeb49158c66
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
Sentry: ebc12276bd17613a114ab359074096b6b3725203
sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
Expand All @@ -196,4 +196,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 911aea8a3150d910789c4f32e348c4d0ff803162

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
27 changes: 25 additions & 2 deletions frontend/lib/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:ehrenamtskarte/about/about_page.dart';
import 'package:ehrenamtskarte/build_config/build_config.dart' show buildConfig;
import 'package:ehrenamtskarte/configuration/settings_model.dart';
Expand All @@ -13,18 +15,20 @@ import 'package:provider/provider.dart';

import 'package:ehrenamtskarte/l10n/translations.g.dart';

import 'package:ehrenamtskarte/routing.dart';

const mapTabIndex = 0;
const identityTabIndex = 2;

class HomePage extends StatefulWidget {
class HomePage extends StatefulWidget with WidgetsBindingObserver {
final int? initialTabIndex;
const HomePage({super.key, this.initialTabIndex});

@override
HomePageState createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
class HomePageState extends State<HomePage> with WidgetsBindingObserver {
late List<AppFlow> appFlows;
int _currentTabIndex = mapTabIndex;

Expand All @@ -34,6 +38,7 @@ class HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_currentTabIndex = widget.initialTabIndex ?? mapTabIndex;
appFlows = [
AppFlow(
Expand Down Expand Up @@ -63,6 +68,24 @@ class HomePageState extends State<HomePage> {
];
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

// Reload map on android devices to solve this issue https://github.com/maplibre/flutter-maplibre-gl/issues/327
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed && _currentTabIndex == mapTabIndex && Platform.isAndroid) {
Navigator.of(context, rootNavigator: true).push(
AppRoute(
builder: (context) => HomePage(),
),
);
}
}

@override
Widget build(BuildContext context) {
final settings = Provider.of<SettingsModel>(context);
Expand Down
9 changes: 4 additions & 5 deletions frontend/lib/map/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class MapContainer extends StatefulWidget {

const mapboxColor = Color(0xFF979897);

class _MapContainerState extends State<MapContainer> implements MapController {
MaplibreMapController? _controller;
class _MapContainerState extends State<MapContainer> with WidgetsBindingObserver implements MapController {
MapLibreMapController? _controller;
Symbol? _symbol;
bool _permissionGiven = false;
bool _isMapInitialized = false;
Expand All @@ -65,15 +65,14 @@ class _MapContainerState extends State<MapContainer> implements MapController {
final statusBarHeight = MediaQuery.of(context).padding.top;
final pixelRatio = MediaQuery.of(context).devicePixelRatio;
final compassMargin = Platform.isIOS ? statusBarHeight / pixelRatio : statusBarHeight * pixelRatio;

final userLocation = widget.userLocation;
final cameraPosition = userLocation != null
? CameraPosition(target: userLocation, zoom: MapContainer.zoomLevelUserLocation)
: CameraPosition(target: MapContainer.centerOfProject, zoom: MapContainer.zoomLevelOverview);

final mapLibreView = Stack(
children: [
MaplibreMap(
MapLibreMap(
initialCameraPosition: cameraPosition,
styleString: config.mapStyleUrl,
// We provide our own attribution menu
Expand Down Expand Up @@ -121,7 +120,7 @@ class _MapContainerState extends State<MapContainer> implements MapController {
: mapLibreView;
}

void _onMapCreated(MaplibreMapController controller) {
void _onMapCreated(MapLibreMapController controller) {
_controller = controller;

setState(() {
Expand Down

0 comments on commit 5634430

Please sign in to comment.