mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Show deprecation warning
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
import 'package:comunic/models/api_request.dart';
 | 
					import 'package:comunic/models/api_request.dart';
 | 
				
			||||||
import 'package:comunic/models/server_config.dart';
 | 
					import 'package:comunic/models/server_config.dart';
 | 
				
			||||||
 | 
					import 'package:version/version.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Server configuration helper
 | 
					/// Server configuration helper
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@@ -20,6 +21,8 @@ class ServerConfigurationHelper {
 | 
				
			|||||||
    final dataConservationPolicy = response["data_conservation_policy"];
 | 
					    final dataConservationPolicy = response["data_conservation_policy"];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _config = ServerConfig(
 | 
					    _config = ServerConfig(
 | 
				
			||||||
 | 
					      minSupportedMobileVersion:
 | 
				
			||||||
 | 
					          Version.parse(response["min_supported_mobile_version"]),
 | 
				
			||||||
      passwordPolicy: PasswordPolicy(
 | 
					      passwordPolicy: PasswordPolicy(
 | 
				
			||||||
        allowMailInPassword: passwordPolicy["allow_email_in_password"],
 | 
					        allowMailInPassword: passwordPolicy["allow_email_in_password"],
 | 
				
			||||||
        allowNameInPassword: passwordPolicy["allow_name_in_password"],
 | 
					        allowNameInPassword: passwordPolicy["allow_name_in_password"],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
import 'package:package_info/package_info.dart';
 | 
					import 'package:package_info/package_info.dart';
 | 
				
			||||||
 | 
					import 'package:version/version.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Application version helper
 | 
					/// Application version helper
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@@ -13,4 +14,7 @@ class VersionHelper {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  /// Get current version information
 | 
					  /// Get current version information
 | 
				
			||||||
  static PackageInfo get info => _info;
 | 
					  static PackageInfo get info => _info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Get current application version, in parsed format
 | 
				
			||||||
 | 
					  static Version get version => Version.parse(info.version);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
import 'package:flutter/widgets.dart';
 | 
					import 'package:flutter/widgets.dart';
 | 
				
			||||||
 | 
					import 'package:version/version.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Server static configuration
 | 
					/// Server static configuration
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@@ -57,12 +58,15 @@ class ServerDataConservationPolicy {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServerConfig {
 | 
					class ServerConfig {
 | 
				
			||||||
 | 
					  final Version minSupportedMobileVersion;
 | 
				
			||||||
  final PasswordPolicy passwordPolicy;
 | 
					  final PasswordPolicy passwordPolicy;
 | 
				
			||||||
  final ServerDataConservationPolicy dataConservationPolicy;
 | 
					  final ServerDataConservationPolicy dataConservationPolicy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const ServerConfig({
 | 
					  const ServerConfig({
 | 
				
			||||||
 | 
					    @required this.minSupportedMobileVersion,
 | 
				
			||||||
    @required this.passwordPolicy,
 | 
					    @required this.passwordPolicy,
 | 
				
			||||||
    @required this.dataConservationPolicy,
 | 
					    @required this.dataConservationPolicy,
 | 
				
			||||||
  })  : assert(passwordPolicy != null),
 | 
					  })  : assert(minSupportedMobileVersion != null),
 | 
				
			||||||
 | 
					        assert(passwordPolicy != null),
 | 
				
			||||||
        assert(dataConservationPolicy != null);
 | 
					        assert(dataConservationPolicy != null);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								lib/ui/dialogs/deprecation_dialog.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								lib/ui/dialogs/deprecation_dialog.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					import 'package:comunic/utils/intl_utils.dart';
 | 
				
			||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Deprecation dialog
 | 
				
			||||||
 | 
					///
 | 
				
			||||||
 | 
					/// @author Pierre Hubert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Show a dialog to warn the user this version of the application is deprecated
 | 
				
			||||||
 | 
					Future<void> showDeprecationDialog(BuildContext context) async {
 | 
				
			||||||
 | 
					  await showDialog(context: context, builder: (c) => _DeprecationDialog());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class _DeprecationDialog extends StatelessWidget {
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 | 
					    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.")),
 | 
				
			||||||
 | 
					      actions: [
 | 
				
			||||||
 | 
					        MaterialButton(
 | 
				
			||||||
 | 
					          onPressed: () => Navigator.pop(context),
 | 
				
			||||||
 | 
					          child: Text(tr("OK")),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -3,6 +3,7 @@ import 'package:comunic/helpers/events_helper.dart';
 | 
				
			|||||||
import 'package:comunic/helpers/server_config_helper.dart';
 | 
					import 'package:comunic/helpers/server_config_helper.dart';
 | 
				
			||||||
import 'package:comunic/helpers/version_helper.dart';
 | 
					import 'package:comunic/helpers/version_helper.dart';
 | 
				
			||||||
import 'package:comunic/helpers/websocket_helper.dart';
 | 
					import 'package:comunic/helpers/websocket_helper.dart';
 | 
				
			||||||
 | 
					import 'package:comunic/ui/dialogs/deprecation_dialog.dart';
 | 
				
			||||||
import 'package:comunic/ui/routes/login_route.dart';
 | 
					import 'package:comunic/ui/routes/login_route.dart';
 | 
				
			||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
 | 
					import 'package:comunic/ui/routes/main_route/main_route.dart';
 | 
				
			||||||
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
 | 
					import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
 | 
				
			||||||
@@ -62,6 +63,9 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      await ServerConfigurationHelper.ensureLoaded();
 | 
					      await ServerConfigurationHelper.ensureLoaded();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (ServerConfigurationHelper.config.minSupportedMobileVersion > VersionHelper.version)
 | 
				
			||||||
 | 
					        await showDeprecationDialog(context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!AccountHelper.isUserIDLoaded) {
 | 
					      if (!AccountHelper.isUserIDLoaded) {
 | 
				
			||||||
        _popToMainRoute();
 | 
					        _popToMainRoute();
 | 
				
			||||||
        _openLoginPage();
 | 
					        _openLoginPage();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -630,6 +630,13 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dartlang.org"
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "2.1.0-nullsafety.3"
 | 
					    version: "2.1.0-nullsafety.3"
 | 
				
			||||||
 | 
					  version:
 | 
				
			||||||
 | 
					    dependency: "direct main"
 | 
				
			||||||
 | 
					    description:
 | 
				
			||||||
 | 
					      name: version
 | 
				
			||||||
 | 
					      url: "https://pub.dartlang.org"
 | 
				
			||||||
 | 
					    source: hosted
 | 
				
			||||||
 | 
					    version: "1.2.0"
 | 
				
			||||||
  wakelock:
 | 
					  wakelock:
 | 
				
			||||||
    dependency: "direct main"
 | 
					    dependency: "direct main"
 | 
				
			||||||
    description:
 | 
					    description:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,6 +88,9 @@ dependencies:
 | 
				
			|||||||
  # Get information about current version
 | 
					  # Get information about current version
 | 
				
			||||||
  package_info: ^0.4.3+4
 | 
					  package_info: ^0.4.3+4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Version manager
 | 
				
			||||||
 | 
					  version: ^1.2.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dev_dependencies:
 | 
					dev_dependencies:
 | 
				
			||||||
  flutter_test:
 | 
					  flutter_test:
 | 
				
			||||||
    sdk: flutter
 | 
					    sdk: flutter
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user