mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 13:20:16 +02:00
Began moving to different download/install process
Previous download plgin was buggy, overcomplicated, and unmaintained. Began switch to a different approach (not done - installs fail). Also, the GitHub API is no longer used (rate limit) - web scraping instead.
This commit is contained in:
@@ -17,16 +17,16 @@ class _AppPageState extends State<AppPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var appsProvider = context.watch<AppsProvider>();
|
||||
App? app = appsProvider.apps[widget.appId];
|
||||
if (app?.installedVersion != null) {
|
||||
appsProvider.getUpdate(app!.id);
|
||||
AppInMemory? app = appsProvider.apps[widget.appId];
|
||||
if (app?.app.installedVersion != null) {
|
||||
appsProvider.getUpdate(app!.app.id);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('${app?.author}/${app?.name}'),
|
||||
title: Text('${app!.app.author}/${app.app.name}'),
|
||||
),
|
||||
body: WebView(
|
||||
initialUrl: app?.url,
|
||||
initialUrl: app.app.url,
|
||||
),
|
||||
bottomSheet: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -39,21 +39,21 @@ class _AppPageState extends State<AppPage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: (app?.installedVersion == null ||
|
||||
appsProvider
|
||||
.checkAppObjectForUpdate(app!)) &&
|
||||
app?.currentDownloadId == null
|
||||
onPressed: (app.app.installedVersion == null ||
|
||||
appsProvider.checkAppObjectForUpdate(
|
||||
app.app)) &&
|
||||
app.downloadProgress == null
|
||||
? () {
|
||||
appsProvider
|
||||
.backgroundDownloadAndInstallApp(app!);
|
||||
appsProvider.downloadAndInstallLatestApp(
|
||||
app.app.id);
|
||||
}
|
||||
: null,
|
||||
child: Text(app?.installedVersion == null
|
||||
child: Text(app.app.installedVersion == null
|
||||
? 'Install'
|
||||
: 'Update'))),
|
||||
const SizedBox(width: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: app?.currentDownloadId != null
|
||||
onPressed: app.downloadProgress != null
|
||||
? null
|
||||
: () {
|
||||
showDialog(
|
||||
@@ -62,12 +62,12 @@ class _AppPageState extends State<AppPage> {
|
||||
return AlertDialog(
|
||||
title: const Text('Remove App?'),
|
||||
content: Text(
|
||||
'This will remove \'${app?.name}\' from Obtainium.${app?.installedVersion != null ? '\n\nNote that while Obtainium will no longer track its updates, the App will remain installed.' : ''}'),
|
||||
'This will remove \'${app.app.name}\' from Obtainium.${app.app.installedVersion != null ? '\n\nNote that while Obtainium will no longer track its updates, the App will remain installed.' : ''}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
appsProvider
|
||||
.removeApp(app!.id)
|
||||
.removeApp(app.app.id)
|
||||
.then((_) {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil(
|
||||
@@ -90,7 +90,8 @@ class _AppPageState extends State<AppPage> {
|
||||
child: const Text('Remove'),
|
||||
),
|
||||
])),
|
||||
if (app?.currentDownloadId != null) const LinearProgressIndicator()
|
||||
if (app.downloadProgress != null)
|
||||
LinearProgressIndicator(value: app.downloadProgress)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:obtainium/pages/add_app.dart';
|
||||
import 'package:obtainium/pages/app.dart';
|
||||
import 'package:obtainium/services/apps_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -31,18 +30,23 @@ class _AppsPageState extends State<AppsPage> {
|
||||
children: appsProvider.apps.values
|
||||
.map(
|
||||
(e) => ListTile(
|
||||
title: Text('${e.author}/${e.name}'),
|
||||
title: Text('${e.app.author}/${e.app.name}'),
|
||||
subtitle:
|
||||
Text(e.installedVersion ?? 'Not Installed'),
|
||||
trailing: e.installedVersion != null &&
|
||||
e.installedVersion != e.latestVersion
|
||||
? const Text('Update Available')
|
||||
: null,
|
||||
Text(e.app.installedVersion ?? 'Not Installed'),
|
||||
trailing: e.downloadProgress != null
|
||||
? Text(
|
||||
'Downloading - ${e.downloadProgress!.toInt()}%')
|
||||
: (e.app.installedVersion != null &&
|
||||
e.app.installedVersion !=
|
||||
e.app.latestVersion
|
||||
? const Text('Update Available')
|
||||
: null),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AppPage(appId: e.id)),
|
||||
builder: (context) =>
|
||||
AppPage(appId: e.app.id)),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user