Ind Upgrade: Switch to direct download option (#226)
This commit is contained in:
commit
7cd5b313de
4 changed files with 54 additions and 33 deletions
|
@ -24,6 +24,6 @@ subprojects {
|
|||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ class SuperLogging {
|
|||
if (_preferences.containsKey(keyShouldReportErrors)) {
|
||||
return _preferences.getBool(keyShouldReportErrors)!;
|
||||
} else {
|
||||
return false;
|
||||
return kDebugMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,6 +253,10 @@
|
|||
"privacy": "Privacy",
|
||||
"terms": "Terms",
|
||||
"checkForUpdates": "Check for updates",
|
||||
"downloadUpdate": "Download",
|
||||
"criticalUpdateAvailable": "Critical update available",
|
||||
"updateAvailable": "Update available",
|
||||
"update": "Update",
|
||||
"checking": "Checking...",
|
||||
"youAreOnTheLatestVersion": "You are on the latest version",
|
||||
"warning": "Warning",
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/core/network.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/services/update_service.dart';
|
||||
import 'package:ente_auth/theme/ente_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:open_filex/open_filex.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class AppUpdateDialog extends StatefulWidget {
|
||||
final LatestVersionInfo? latestVersionInfo;
|
||||
|
@ -20,6 +23,7 @@ class AppUpdateDialog extends StatefulWidget {
|
|||
class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final enteTextTheme = getEnteTextTheme(context);
|
||||
final List<Widget> changelog = [];
|
||||
for (final log in widget.latestVersionInfo!.changelog) {
|
||||
changelog.add(
|
||||
|
@ -41,18 +45,19 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
Text(
|
||||
widget.latestVersionInfo!.name!,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(8)),
|
||||
if (changelog.isNotEmpty)
|
||||
const Text(
|
||||
"Changelog",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(4)),
|
||||
if (changelog.isNotEmpty) const Padding(padding: EdgeInsets.all(4)),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: changelog,
|
||||
|
@ -69,18 +74,12 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
},
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ApkDownloaderDialog(widget.latestVersionInfo);
|
||||
},
|
||||
barrierDismissible: false,
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
"Update",
|
||||
onPressed: () => launchUrlString(
|
||||
widget.latestVersionInfo!.url!,
|
||||
mode: LaunchMode.externalApplication,
|
||||
),
|
||||
child: Text(
|
||||
context.l10n.downloadUpdate,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -91,8 +90,24 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
return WillPopScope(
|
||||
onWillPop: () async => !shouldForceUpdate,
|
||||
child: AlertDialog(
|
||||
title: Text(
|
||||
shouldForceUpdate ? "Critical update available" : "Update available",
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.auto_awesome_outlined,
|
||||
size: 24,
|
||||
color: getEnteColorScheme(context).strokeMuted,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Text(
|
||||
shouldForceUpdate
|
||||
? context.l10n.criticalUpdateAvailable
|
||||
: context.l10n.updateAvailable,
|
||||
style: enteTextTheme.h3Bold,
|
||||
),
|
||||
],
|
||||
),
|
||||
content: content,
|
||||
),
|
||||
|
@ -147,6 +162,7 @@ class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
|
|||
|
||||
Future<void> _downloadApk() async {
|
||||
try {
|
||||
if (!File(_saveUrl!).existsSync()) {
|
||||
await Network.instance.getDio().download(
|
||||
widget.versionInfo!.url!,
|
||||
_saveUrl,
|
||||
|
@ -156,6 +172,7 @@ class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
|
|||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
OpenFilex.open(_saveUrl);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue