Switched to package names as app ids (#69)

* Fixes #14 (although detection is disabled in background processes due to the bug described in #60)
    * Added App icons and basic installed detection
    * Real Package Names Used as IDs + App Icons (INCONVENIENT FOR PREVIOUS VERSION USERS)
    * Switch to using extracted names (no custom names)

* Fixes #57

* Fixes #67

* Fixes #64

* Fixes #61

* Commented out APKMirror and added code to remove their Apps

* Updated README

* Switched to Flutter stable (causes some UI elements to switch back to the old material design style, but this will be fixed in later Flutter releases)

* BG task silently retries on network errors

* Updated screenshots
This commit is contained in:
Imran Remtulla
2022-10-29 13:13:28 -04:00
committed by GitHub
parent a954a627fd
commit d1a3529036
16 changed files with 575 additions and 432 deletions

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:obtainium/components/generated_form.dart';
import 'package:obtainium/components/generated_form_modal.dart';
import 'package:obtainium/providers/apps_provider.dart';
import 'package:obtainium/providers/settings_provider.dart';
@@ -46,6 +45,7 @@ class _AppPageState extends State<AppPage> {
body: RefreshIndicator(
child: settingsProvider.showAppWebpage
? WebView(
backgroundColor: Theme.of(context).colorScheme.background,
initialUrl: app?.app.url,
javascriptMode: JavascriptMode.unrestricted,
)
@@ -56,8 +56,18 @@ class _AppPageState extends State<AppPage> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
app?.installedInfo != null
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.memory(
app!.installedInfo!.icon!,
scale: 1.5,
)
])
: Container(),
Text(
app?.app.name ?? 'App',
app?.installedInfo?.name ?? app?.app.name ?? 'App',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displayLarge,
),
@@ -126,7 +136,8 @@ class _AppPageState extends State<AppPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (app?.app.installedVersion != app?.app.latestVersion)
if (app?.app.installedVersion != null &&
app?.app.installedVersion != app?.app.latestVersion)
IconButton(
onPressed: app?.downloadProgress != null
? null
@@ -135,8 +146,8 @@ class _AppPageState extends State<AppPage> {
context: context,
builder: (BuildContext ctx) {
return AlertDialog(
title: Text(
'App Already ${app?.app.installedVersion == null ? 'Installed' : 'Updated'}?'),
title: const Text(
'App Already up to Date?'),
actions: [
TextButton(
onPressed: () {
@@ -161,54 +172,13 @@ class _AppPageState extends State<AppPage> {
.pop();
},
child: const Text(
'Yes, Mark as Installed'))
'Yes, Mark as Updated'))
],
);
});
},
tooltip: 'Mark as Installed',
icon: const Icon(Icons.done))
else
IconButton(
onPressed: app?.downloadProgress != null
? null
: () {
showDialog(
context: context,
builder: (BuildContext ctx) {
return AlertDialog(
title: const Text(
'App Not Installed?'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context)
.pop();
},
child: const Text('No')),
TextButton(
onPressed: () {
HapticFeedback
.selectionClick();
var updatedApp = app?.app;
if (updatedApp != null) {
updatedApp
.installedVersion =
null;
appsProvider.saveApps(
[updatedApp]);
}
Navigator.of(context)
.pop();
},
child: const Text(
'Yes, Mark as Not Installed'))
],
);
});
},
tooltip: 'Mark as Not Installed',
icon: const Icon(Icons.no_cell_outlined)),
tooltip: 'Mark as Updated',
icon: const Icon(Icons.done)),
if (source != null &&
source.additionalDataFormItems.isNotEmpty)
IconButton(
@@ -220,30 +190,15 @@ class _AppPageState extends State<AppPage> {
builder: (BuildContext ctx) {
return GeneratedFormModal(
title: 'Additional Options',
items: [
...source
.additionalDataFormItems,
[
GeneratedFormItem(
label: 'App Name',
required: true)
]
],
items: source
.additionalDataFormItems,
defaultValues: app != null
? [
...app
.app.additionalData,
app.app.name
]
: [
...source
.additionalDataDefaults
]);
? app.app.additionalData
: source
.additionalDataDefaults);
}).then((values) {
if (app != null && values != null) {
var changedApp = app.app;
var name = values.removeLast();
changedApp.name = name;
changedApp.additionalData = values;
appsProvider.saveApps(
[changedApp]).then((value) {
@@ -265,12 +220,18 @@ class _AppPageState extends State<AppPage> {
? () {
HapticFeedback.heavyImpact();
appsProvider
.downloadAndInstallLatestApp(
.downloadAndInstallLatestApps(
[app!.app.id],
context).then((res) {
if (res.isNotEmpty && mounted) {
Navigator.of(context).pop();
}
}).catchError((e) {
ScaffoldMessenger.of(context)
.showSnackBar(
SnackBar(
content: Text(e.toString())),
);
});
}
: null,
@@ -288,7 +249,7 @@ class _AppPageState extends State<AppPage> {
return AlertDialog(
title: const Text('Remove App?'),
content: Text(
'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.' : ''}'),
'This will remove \'${app?.installedInfo?.name ?? 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: () {