From 1ea286f3efbb6e2de9e6f46e84fa894d0315a8eb Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 20 Feb 2021 09:59:21 +0100 Subject: [PATCH] Add download link on deprecation dialog --- lib/helpers/server_config_helper.dart | 2 ++ lib/models/server_config.dart | 6 ++++++ lib/ui/dialogs/deprecation_dialog.dart | 16 ++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/helpers/server_config_helper.dart b/lib/helpers/server_config_helper.dart index 818b233..c2e2511 100644 --- a/lib/helpers/server_config_helper.dart +++ b/lib/helpers/server_config_helper.dart @@ -24,6 +24,8 @@ class ServerConfigurationHelper { minSupportedMobileVersion: Version.parse(response["min_supported_mobile_version"]), termsURL: response["terms_url"], + playStoreURL: response["play_store_url"], + androidDirectDownloadURL: response["android_direct_download_url"], passwordPolicy: PasswordPolicy( allowMailInPassword: passwordPolicy["allow_email_in_password"], allowNameInPassword: passwordPolicy["allow_name_in_password"], diff --git a/lib/models/server_config.dart b/lib/models/server_config.dart index baf5367..ebcf4ed 100644 --- a/lib/models/server_config.dart +++ b/lib/models/server_config.dart @@ -60,16 +60,22 @@ class ServerDataConservationPolicy { class ServerConfig { final Version minSupportedMobileVersion; final String termsURL; + final String playStoreURL; + final String androidDirectDownloadURL; final PasswordPolicy passwordPolicy; final ServerDataConservationPolicy dataConservationPolicy; const ServerConfig({ @required this.minSupportedMobileVersion, @required this.termsURL, + @required this.playStoreURL, + @required this.androidDirectDownloadURL, @required this.passwordPolicy, @required this.dataConservationPolicy, }) : assert(minSupportedMobileVersion != null), assert(termsURL != null), + assert(playStoreURL != null), + assert(androidDirectDownloadURL != null), assert(passwordPolicy != null), assert(dataConservationPolicy != null); } diff --git a/lib/ui/dialogs/deprecation_dialog.dart b/lib/ui/dialogs/deprecation_dialog.dart index c5ec3db..f7f0f2d 100644 --- a/lib/ui/dialogs/deprecation_dialog.dart +++ b/lib/ui/dialogs/deprecation_dialog.dart @@ -1,5 +1,7 @@ +import 'package:comunic/helpers/server_config_helper.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; /// Deprecation dialog /// @@ -16,11 +18,21 @@ class _DeprecationDialog extends StatelessWidget { return AlertDialog( title: Text(tr("Deprecated application version")), content: Text(tr( - "This version of the mobile application is deprecated. You might still be able to use it, but some features will not work. We recommend you to update to the latest version of the application.")), + "This version of the Comunic application is deprecated. You might still be able to use it, but some features may not work. We recommend you to update to the latest version of the application.")), actions: [ + MaterialButton( + onPressed: () => + launch(ServerConfigurationHelper.config.playStoreURL), + child: Text(tr("Go to the Play Store")), + ), + MaterialButton( + onPressed: () => + launch(ServerConfigurationHelper.config.androidDirectDownloadURL), + child: Text(tr("Download update outside Play Store")), + ), MaterialButton( onPressed: () => Navigator.pop(context), - child: Text(tr("OK")), + child: Text(tr("Use the old application anyway")), ) ], );