mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-31 11:52:16 +00:00
Adapted app updater
This commit is contained in:
parent
578e606b83
commit
5660aefdc5
3 changed files with 39 additions and 11 deletions
|
@ -55,15 +55,25 @@ class _BaseState extends State<Base> with WidgetsBindingObserver {
|
|||
}
|
||||
|
||||
Future<GitHubRelease?> checkInstallationSource() async {
|
||||
if (Platform.isAndroid) {
|
||||
Source installationSource = await StoreChecker.getSource;
|
||||
if (installationSource != Source.IS_INSTALLED_FROM_PLAY_STORE) {
|
||||
final result = await checkAppUpdatesGitHub();
|
||||
if (result['result'] == 'success') {
|
||||
if (updateExists(widget.appConfigProvider.getAppInfo!.version, result['body'].tagName)) {
|
||||
final result = await checkAppUpdatesGitHub();
|
||||
if (result['result'] == 'success') {
|
||||
final update = updateExists(widget.appConfigProvider.getAppInfo!.version, result['body'].tagName);
|
||||
if (update == true) {
|
||||
if (Platform.isAndroid) {
|
||||
Source installationSource = await StoreChecker.getSource;
|
||||
if (installationSource == Source.IS_INSTALLED_FROM_PLAY_STORE) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return result['body'];
|
||||
}
|
||||
}
|
||||
else if (Platform.isIOS) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return result['body'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -231,7 +231,7 @@ class SettingsWidget extends StatelessWidget {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
if (Platform.isAndroid) IconButton(
|
||||
onPressed: () => openUrl(Urls.playStore),
|
||||
icon: SvgPicture.asset(
|
||||
'assets/resources/google-play.svg',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
@ -22,14 +24,30 @@ class UpdateModal extends StatefulWidget {
|
|||
class _UpdateModalState extends State<UpdateModal> {
|
||||
bool doNotRemember = false;
|
||||
|
||||
String getDownloadLink() {
|
||||
return widget.gitHubRelease.assets.firstWhere((item) => item.browserDownloadUrl.contains('apk')).browserDownloadUrl;
|
||||
String? getDownloadLink() {
|
||||
if (Platform.isAndroid) {
|
||||
return widget.gitHubRelease.assets.firstWhere((item) => item.browserDownloadUrl.contains('apk')).browserDownloadUrl;
|
||||
}
|
||||
else if (Platform.isMacOS) {
|
||||
return widget.gitHubRelease.assets.firstWhere((item) => item.browserDownloadUrl.contains('macOS')).browserDownloadUrl; // macOS package is a zip
|
||||
}
|
||||
else if (Platform.isWindows) {
|
||||
return widget.gitHubRelease.assets.firstWhere((item) => item.browserDownloadUrl.contains('exe')).browserDownloadUrl;
|
||||
}
|
||||
else if (Platform.isLinux) {
|
||||
return widget.gitHubRelease.assets.firstWhere((item) => item.browserDownloadUrl.contains('deb')).browserDownloadUrl;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
|
||||
final downloadLink = getDownloadLink();
|
||||
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Column(
|
||||
|
@ -104,10 +122,10 @@ class _UpdateModalState extends State<UpdateModal> {
|
|||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
if (downloadLink != null) TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
widget.onDownload(getDownloadLink(), widget.gitHubRelease.tagName);
|
||||
widget.onDownload(downloadLink, widget.gitHubRelease.tagName);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.download)
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue