mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat(updater): download successful dialog (#938)
This commit is contained in:
parent
35e99cb014
commit
d051ae576b
@ -24,11 +24,13 @@
|
|||||||
"WIP": "Work in progress...",
|
"WIP": "Work in progress...",
|
||||||
"noInstallations": "No patched applications installed",
|
"noInstallations": "No patched applications installed",
|
||||||
"installed": "Installed",
|
"installed": "Installed",
|
||||||
|
"installUpdate": "Continue to install the update?",
|
||||||
"updateDialogTitle": "Update Manager",
|
"updateDialogTitle": "Update Manager",
|
||||||
"updateChangelogTitle": "Changelog",
|
"updateChangelogTitle": "Changelog",
|
||||||
"notificationTitle": "Update downloaded",
|
"notificationTitle": "Update downloaded",
|
||||||
"notificationText": "Tap to install the update",
|
"notificationText": "Tap to install the update",
|
||||||
"downloadingMessage": "Downloading update...",
|
"downloadingMessage": "Downloading update...",
|
||||||
|
"downloadedMessage": "Update downloaded!",
|
||||||
"installingMessage": "Installing update...",
|
"installingMessage": "Installing update...",
|
||||||
"errorDownloadMessage": "Unable to download update",
|
"errorDownloadMessage": "Unable to download update",
|
||||||
"errorInstallMessage": "Unable to install update",
|
"errorInstallMessage": "Unable to install update",
|
||||||
|
@ -170,6 +170,7 @@ class RevancedAPI {
|
|||||||
|
|
||||||
updateManagerDownloadProgress(progress);
|
updateManagerDownloadProgress(progress);
|
||||||
} else if (result is FileInfo) {
|
} else if (result is FileInfo) {
|
||||||
|
disposeManagerUpdateProgress();
|
||||||
// The download is complete; convert the FileInfo object to a File object
|
// The download is complete; convert the FileInfo object to a File object
|
||||||
outputFile = File(result.file.path);
|
outputFile = File(result.file.path);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:app_installer/app_installer.dart';
|
import 'package:app_installer/app_installer.dart';
|
||||||
import 'package:cross_connectivity/cross_connectivity.dart';
|
import 'package:cross_connectivity/cross_connectivity.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -39,6 +38,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
List<PatchedApplication> patchedInstalledApps = [];
|
List<PatchedApplication> patchedInstalledApps = [];
|
||||||
List<PatchedApplication> patchedUpdatableApps = [];
|
List<PatchedApplication> patchedUpdatableApps = [];
|
||||||
String? _latestManagerVersion = '';
|
String? _latestManagerVersion = '';
|
||||||
|
File? downloadedApk;
|
||||||
|
|
||||||
Future<void> initialize(BuildContext context) async {
|
Future<void> initialize(BuildContext context) async {
|
||||||
_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
|
_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
|
||||||
@ -162,74 +162,134 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateManager(BuildContext context) async {
|
Future<void> updateManager(BuildContext context) async {
|
||||||
|
final ValueNotifier<bool> downloaded = ValueNotifier(false);
|
||||||
try {
|
try {
|
||||||
_toast.showBottom('homeView.downloadingMessage');
|
_toast.showBottom('homeView.downloadingMessage');
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => SimpleDialog(
|
builder: (context) => ValueListenableBuilder(
|
||||||
contentPadding: const EdgeInsets.all(16.0),
|
valueListenable: downloaded,
|
||||||
title: I18nText(
|
builder: (context, value, child) {
|
||||||
'homeView.downloadingMessage',
|
return SimpleDialog(
|
||||||
child: Text(
|
contentPadding: const EdgeInsets.all(16.0),
|
||||||
'',
|
title: I18nText(
|
||||||
style: TextStyle(
|
!value
|
||||||
fontSize: 20,
|
? 'homeView.downloadingMessage'
|
||||||
fontWeight: FontWeight.w500,
|
: 'homeView.downloadedMessage',
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
child: Text(
|
||||||
),
|
'',
|
||||||
),
|
style: TextStyle(
|
||||||
),
|
fontSize: 20,
|
||||||
children: [
|
fontWeight: FontWeight.w500,
|
||||||
Column(
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.new_releases_outlined,
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8.0),
|
|
||||||
Text(
|
|
||||||
'$_latestManagerVersion',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16.0),
|
|
||||||
StreamBuilder<double>(
|
|
||||||
initialData: 0.0,
|
|
||||||
stream: _revancedAPI.managerUpdateProgress.stream,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return LinearProgressIndicator(
|
|
||||||
value: snapshot.data! * 0.01,
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
|
||||||
Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16.0),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: CustomMaterialButton(
|
|
||||||
label: I18nText('cancelButton'),
|
|
||||||
onPressed: () {
|
|
||||||
_revancedAPI.disposeManagerUpdateProgress();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.new_releases_outlined,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8.0),
|
||||||
|
Text(
|
||||||
|
'$_latestManagerVersion',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16.0),
|
||||||
|
if (!value)
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
StreamBuilder<double>(
|
||||||
|
initialData: 0.0,
|
||||||
|
stream: _revancedAPI.managerUpdateProgress.stream,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return LinearProgressIndicator(
|
||||||
|
value: snapshot.data! * 0.01,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16.0),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: CustomMaterialButton(
|
||||||
|
label: I18nText('cancelButton'),
|
||||||
|
onPressed: () {
|
||||||
|
_revancedAPI.disposeManagerUpdateProgress();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (value)
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
I18nText(
|
||||||
|
'homeView.installUpdate',
|
||||||
|
child: Text(
|
||||||
|
'',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16.0),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: CustomMaterialButton(
|
||||||
|
isFilled: false,
|
||||||
|
label: I18nText('cancelButton'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8.0),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: CustomMaterialButton(
|
||||||
|
label: I18nText('updateButton'),
|
||||||
|
onPressed: () async {
|
||||||
|
await AppInstaller.installApk(
|
||||||
|
downloadedApk!.path,);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final File? managerApk = await downloadManager();
|
final File? managerApk = await downloadManager();
|
||||||
if (managerApk != null) {
|
if (managerApk != null) {
|
||||||
|
downloaded.value = true;
|
||||||
|
downloadedApk = managerApk;
|
||||||
// await flutterLocalNotificationsPlugin.zonedSchedule(
|
// await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||||
// 0,
|
// 0,
|
||||||
// FlutterI18n.translate(
|
// FlutterI18n.translate(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user