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